I\'m getting this error
Exception in thread \"main\" java.lang.NoClassDefFoundError: javafx/application/Ap
plication
at java.lang.ClassLoader.defineC
IntelliJ and maybe other IDE's do not refactor your Run/Debug configuration. You must manually change your package name preceding the name of your Main class. For instance, change 'sample.Main' to 'com.company.package.ui.Main' so it will launch correctly next time you try to run it. The IDE might have already marked the Run/Debug button with a red cross because it couldn't find the main class. It also gives a warning when you open the Run/Debug configuration.
I had a problem of not finding the Pair class from javafx.
It seems that vanilla eclipse (without the e(fx)clipse extension) doesn't search the javaFX runtime jar included with java.
I just added to my eclipse project build path this external jar (or if you are in a debug configuration, add the external jar in the JRE tab of the debug configuration):
$JAVA_HOME/jre/lib/ext/jfxrt.jar
(replace JAVA_HOME with your jdk folder)
For me it was in /installs/jdk1.8.0_211/jre/lib/ext/jfxrt.jar
I use maven and I just run this mvn install:install-file -Dfile="/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfxrt.jar" -DgroupId=com.oracle.javafx -DartifactId=javafx -Dversion=2.2 -Dpackaging=jar
in terminal(Maybe a little difference in Windows.). Then maven will install jfxrt.jar
then you can simply reference it as
<dependency>
<groupId>com.oracle.javafx</groupId>
<artifactId>javafx</artifactId>
<version>2.2</version>
</dependency>
I already answered it on "Ask ubntu". I recommend you to go with https://openjfx.io/openjfx-docs/ .i am using Eclipse IDE but it works for all IDE
Then you can refer to this global variable when setting the VM options as:
In IDE Right-click on project->Run As -> Run Configuration ->Arguments->VM Arguments
For Windows,
--module-path "\path to javafx\lib" --add-modules javafx.controls,javafx.fxml
For Linux,
--module-path /path to javafx/lib --add-modules javafx.controls,javafx.fxml
Using java 8 shouldn't give this problem but it did for me
I created my jar initially from Eclipse Export -> Runnable Jar and it was fine. When I moved to Maven it failed with the above.
Comparing the two jars showed that nothing fx related was packaged with the jar (as I'd expect) but that the Eclipse generated manifest had Class-Path: .
in it. Getting maven to package the jar with the following worked for me (with Java 8)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.pg.fxapplication.Main</mainClass>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>