java.lang.NoClassDefFoundError: javafx/application/Application
I installed OpenJDK-11 as described here.
I ran sudo apt install openjfx
My java version:
$ java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu1, mixed mode, sharing)But still I get ava.lang.NoClassDefFoundError: javafx/application/Application which indicates that the jre cannot find the FX classes.
3 Answers
You are getting this error because your runtime PATH to javafx is probably incorrect or missing.
Please, follow these steps:
Check the path of JavaFX. (example: /usr/share/openjfx/lib/)
Then run command:
java --module-path $FX-PATH --add-modules javafx.controls -jar sample.jarwhere $FX-PATH should be set or replaced with mentioned JavaFX path.
If you need to add more modules, you can specify them in --add-modules parameter.
(--add-modules javafx.controls,javafx.fxml)
Java FX is no longer packaged with the Java runtime. You must download and package the Jar with JavaFX runtime, see in order to learn how best to get this up and running.
I recommend you to go with .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.fxmlFor Linux,
--module-path /path to javafx/lib --add-modules javafx.controls,javafx.fxml More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"