Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

Viewed 5922

When I try to build my javafx application in intellij as a JavaFX Application and I run the jar in console with

java -jar RaspberryShell.jar

I get this error:

Error: Could not find or load main class de.Jan.Raspberry.Shell.Main
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

I also set the main class in the artifact that shouldn't be a problem and the code runs fine if I run it direct in intellij.

Does anyone have ideas?

3 Answers

Try to add this to the path:

--module-path /usr/local/javafx-sdk-14.0.1/lib --add-modules javafx.controls,javafx.fxml

Just change /usr/local/javafx-sdk-14.0.1/lib to the directory which contain javafx. The lib directory should contain some .jar files, including javafx.fxml.jar

Your runtime Java does not include JavaFX. Change to one who does.

When you run it, click on the drop down arrow -> Run configurations -> Arguments Then paste the following into VM arguments: (Replace with your own path for lib) --module-path "C:\Program Files\FX\javafx-sdk-11.0.2\lib" --add-modules javafx.controls,javafx.fxml Press apply and run!

Related