1
votes

I wrote a java program for school and it compiled properly but when I tried to run it I got this message:

Exception in thread "main" java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel at Main.main(Main.java:5) Caused by: java.lang.ClassNotFoundException: javafx.embed.swing.JFXPanel at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 1 more

I have checked several sources but none match my exact problem. I use java version 11.0.2 and all this is being run on a mac and IDE is Atom.

$ java -version java version "11.0.2" 2019-01-15 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

1

1 Answers

2
votes

The exception means that the JavaFX components are not present in the classpath.

In java 11, javaFX has been moved outside the JDK. See for example this article.

You need to download the javaFX module for your platform, and add it yourself. See those instructions.