Thanks to the module system of Java 9 and the removal of JavaFX from Java 11, we got some problems running JavaFX apps without older versions of Java.

Example: JiraClient

At the office, we use JiraClient by Almworks to make Jira usage and time tracking a lot easier. Only problem is that only Java 8 is supported thanks to the included JavaFX.

But the latest LTS version of Java is 11, so it would be nice to use this one instead of an older version.

OpenJFX to the rescue

JavaFX can be replaced by its open-source successor. Either install the package available in your OS, or install it manually. I’m using Ubuntu 18.04.3 and the package openjfx is version 11, so I’ll just use it:

apt install -y \
    openjdk-11-jdk \
    openjdk-11-source \
    openjdk-11-doc \
    openjfx

Or you can download the appropiate version, save it to a good location because we need that later on.

$JAVA_OPTIONS

We need to modify the $JAVA_OPTIONS of the app to load the correct modules, here is JiraClient as an example:

# ORIGINAL
JAVA_OPTIONS="-Xmx600m·-Duse.metal=true"¬

# MODIFIED
JAVA_OPTIONS="-Xmx600m·-Duse.metal=true·--module-path=/usr/share/openjfx/lib·--add-modules javafx.swing,javafx.fxml,javafx.controls,javafx.web"¬

The --module-path is the default location if you installed the Ubuntu package, adapt accordingly if you installed it manually.

Additional libraries

Some more modules were removed from the JDK, so you need to add them back and load them. For example JiraClient also needs Java XML Bindings (JAXB), we could either save it to a shared location and reference it in $JAVA_OPTIONS, or copy it directly into the lib directory of the JiraClient.

That’s it!

Well, your app should now run again. If not, the crash will tell you what module is still missing.