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 the all the modules. So you end up with a smaller, more lightweight program.
Did you know...
IDRsolutions offers a whole range of online file converters to convert PDF and Microsoft Excel, Word and Office Documents to HTML5, SVG or image formats?
It is free to use for single file conversions and also includes Developer links if you want to use our commercial software for bulk conversions. Find out more on this page