How to bundle and launch a native Mac/Windows application with Java 11?

Viewed 1351

Unfortunately the javapackager tool will be removed with JDK 11 - as it is part of JavaFX, which will also be removed. Hence, there will be no "official" and easy way to create native Java application bundles for Mac or Windows any longer.

I tried to re-use the native launcher files generated by Java 9/10's javapackager (on Mac: my.app/Contents/MacOS/my) and they still seem to work with JDK 11. However that's a bit of a dirty solution. Any ideas about how to natively package and launch applications with Java 11 and beyond (Mac platform preferred)?

2 Answers

You can use the jlink command, which will bundle your modules into a custom runtime image. This is a bit different from javapackager though, requiring you to use modules for it to work properly. You might be able to get it working without modules if you manually specify all the modules from the JRE that are required.

As ccpizza commented above:

As of JDK14 you can now use jpackage as shown here: stackoverflow.com/a/66511673/191246 (still incubating though) – ccpizza

Related