In Java 11, JavaFX was removed from the SDK. It is now in its own separate module, and if you want to use it in your application you will need to specifically include it.
Where can I get the JavaFX SDK from?
How do I include it in a modular application?
If you are running a modular Java application from the command line, you need to add the JavaFX module to the classpath.
I have tested this with our Java PDF Library JPedal, as the Viewer has some features which require JavaFX. The command I used is:
java --module-path "path/to/javafx-sdk-11/lib" --add-modules=javafx.controls --add-modules=javafx.swing -jar "path/to/jpedal.jar"
In the example above:
–module-path “path/to/javafx-sdk-11/lib” adds the JavaFX SDK to the module path.
–add-modules=javafx.controls –add-modules=javafx.swing adds the specific JavaFX modules needed to run the application. JPedal requires the controls module and the swing module, so those are the 2 I have added. The list of the available modules can be found in the documentation here.
The good thing about modularisation is that you only use the bits you need to run your application. You don’t need the whole JavaFX SDK if you are not using all the modules. So you end up with a smaller, more lightweight program.