Filling the Packager gap

Sverre Moe at
Thu Sep 27 08:42:36 UTC 2018

Den tor. 27. sep. 2018 kl. 00:49 skrev Kevin Rushforth <
kevin.rushforth at>:

> No, jlink won't link in a non-modular application. So the steps are:
> 1) Run jlink to create a Java runtime image, possibly stripped down, and
> include the javafx.* modules you need
> 2) Run jpackager to package your non-modular application with the above
> Java runtime image.
> -- Kevin

So we have to create the image with the jlink first before we use
jpackager, and we have to link in with the javafx modules. We cannot use
the javafx dependencies in the project?

jlink --add-modules=ALL-SYSTEM --output image
Error: Module ALL-SYSTEM not found

The just to make sure we have everything we need I add the actual modules
jlink --add-modules=java.base --add-modules=java.desktop --add-modules=java.xml --add-modules=java.prefs
--add-modules=java.logging --output image

Linking in with the JavaFX jmods from Gluon:
jlink --add-modules=java.base --add-modules=java.desktop --add-modules=java.xml --add-modules=java.prefs
--add-modules=java.logging --module-path /usr/java/javafx-jmods-11/
--add-modules=javafx.base --add-modules=javafx.controls
--add-modules=javafx.swing --output image

I managed to build our Java 8 project with Java 11, using the JavaFX
Then using jpackager with the runtime image from jlink
/usr/java/jpackager/jpackager create-installer --input
build/distributions/application-1.0.0-SNAPSHOT/lib/ --output outputDir
--runtime-image image/ --verbose --echo-mode --main-jar

Running the application image from jpackager
First try:
I thought I had added all necessary modules to the runtime image, but I
needed one more,

Second try:
InteropFactory: cannot load
Exception in thread "GUIBuilderWorker" java.lang.IllegalAccessError: class
com.sun.javafx.embed.swing.oldimpl.SwingNodeInteropO (in module
javafx.swing) cannot access class sun.swing.JLightweightFrame (in module
java.desktop) because module java.desktop does not export sun.swing to
module javafx.swing



The module java.desktop should include the AWT/Swing.

At least I now have been able to create an native application using both
jlink and the new jpackager.


More information about the openjfx-dev mailing list