I want to be able to play sound from mp3 files for which I saw posts recommending the usage of JavaFX. I implemented the MediaPlayer and initialized the JFXPanel and in eclipse, everything works lovely.
Yet when I export to a runnable jar, and try running the program, I get the following error message: java.lang.NoClassDefFoundError: javafx/scene/media/MediaException.
I presume this is from the exclusion of JavaFX in the newer JRE versions (which I came across during my search to a solution). My main question is how do I ship the jar with JavaFX? Do I have to include a jar, and if yes, where do I get it? Because eclipse doesn't seem to package JavaFX into my runnable if I'm not mistaken.
Here an example which, for me, already triggers this behavior:
// This would throw a java.lang.NoClassDefFoundError for the JFXPanel but is effectively the same problem
public class Test extends Application
{
public static void main(String[] Args)
{
launch(Args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World!");
StackPane root = new StackPane();
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}
}
Thank you for your help!