Felicyta
Felicyta

Reputation: 95

package javafx.media does not exist

I'm new to programming and don't know what to do... jGRASP gives this error (the title) when i try to run an mp3 file using java via this code :

import javafx.scene.media.MediaPlayer;
import javafx.scene.media.Media;

public class hehe{

  public static void main(String[]args){

    String krow="hoho.mp3";
    Media trial = new Media(krow);
    MediaPlayer Ply = new MediaPlayer(trial);
    Ply.play();

  }

}

I searched for a solution but couldn't find one.

Upvotes: 4

Views: 6715

Answers (1)

An SO User
An SO User

Reputation: 24998

You need to download e(fx)clipse plugin or use NetBeans or IntelliJ. If you are using 'regular' Eclipse, you need to add jfxrt.jar to your classpath.

What you are using is JavaFX. It comes along with your JDK. However, jfxrt.jar is not on standard classpath.

In spite of resolving that, your program won't run because running JavaFX program is different from running 'usual' Java programs. You need to extend the Application class and create a scene graph.

Have a look here on how to get started.

Upvotes: 3

Related Questions