Skip to content
Advertisement

Bundle JavaFX app with openjdk 11 + runtime

I’ve created a small HelloWorld Java app that relies on OpenJDK 11 and JavaFX. The app is packaged in a jar file which can only be run if I have installed Java 11 and JavaFX on my system separately.

Now I’d like to convert my jar into a self-contained Java application which includes JavaFX and a fully-functional Java runtime environment. This will allow me to run my app without installing OpenJDK 11 (which presents technical hurdles such as setting PATH correctly etc).

I can find information about creating self-contained Java applications on Java 10 but I cannot find information about bundling a Java app with OpenJDK 11 and JavaFX.

How can I ship a self-contained Java app (which includes a java runtime) with OpenJDK 11 and JavaFX?

Advertisement

Answer

Modular Java, jlink, & jpackage

Follow these tutorials found at the new home for JavaFX after having been spun out of Oracle to Gluon.

You will need to write code using modular Java. Add JavaFX 11 as a dependency to your project. And use the new linking/packaging tools to bundle a subset of the JDK within your app.

Learn about:

No more JRE

Oracle no longer intends for end-users to be installing a JRE or a JDK. Java Applets in a browser and Java Web Start app delivery are both being phased out, leaving the end-user with no need for a JRE. Java-based apps are expected to bundle their own Java implementation. The only folks consciously installing a JDK will be developers & server-side sysadmins.

Important:

  • Understand clearly the nature of the OpenJDK project, as explained in Wikipedia.
  • Know that Oracle has committed to feature-parity between its own branded Oracle JDK and the OpenJDK project. This commitment includes donations of previously-commercial features such as Flight Recorder and Mission Control.
  • OpenJFX, the open-source development of JavaFX, is a part of the OpenJDK project. OpenJFX may or may not be included in a build of OpenJDK. The Java specifications do not require JavaFX functionality.
  • At least two vendors provide an edition of their JDK product that comes bundled with the OpenJFX libraries:
    • ZuluFX from Azul Systems
    • LibericaFX from BellSoft
  • Read this white paper by Oracle of 2018-03, Java Client Roadmap Update
  • Read the white paper Java Is Still Free, authored by key members of the Java community.

Here is a flowchart diagram that may help you finding and deciding amongst the various vendors providing a Java 11 implementation.

Flowchart guiding you in choosing a vendor for a Java 11 implementation


Motivations in choosing a vendor for Java

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement