Distributing JavaFX 11 Application

Sverre Moe sverre.moe at gmail.com
Wed Feb 20 19:49:57 UTC 2019

You could use the new jpackage to create a native runtime of your
The jpackager is now targeted for JDK 13, but can still be used to create a
native Java 11 application.

You can download an EA build of JDK 13 with jpackage

You would need to build on each platform, Linux, Windows, Mac.

You mentioned you use Maven. When Java 9 came out I had already moved over
to Gradle, so not familiar with the maven configuration.
Here is a Gradle task to create a Java 11 runtime using jlink with the Java
11 jmods

task createRuntime(type: Exec) {
    dependsOn installDist


    doFirst {
        delete "${buildDir}/runtime"

    def libDir = new File(installDist.outputs.files.singleFile, "lib").path

    commandLine '/usr/java/jdk-11/bin/jlink',
        '--module-path', "/usr/java/jdk-11/jmods:${libDir}",
        '--add-modules', 'eu.yourmodule.application',
        '--output', "${buildDir}/runtime"

You then use this runtime with jpackage to create a native application
image or installer.

task createPackage(type: Exec) {
    dependsOn createRuntime

    commandLine '/usr/java/jdk-13/bin/jpackage', 'create-installer',
        '--name', project.name,
        '--app-version', project.version,
        '--module', "${mainClassName}",
        '--resource-dir', "${buildDir}/package",
        '--runtime-image', "${buildDir}/runtime",
        '--output', "${buildDir}/native"


Den ons. 20. feb. 2019 kl. 19:57 skrev Nicolas Therrien <
nicolas.therrien at motorolasolutions.com>:

> Hi!
> What is the proper way to create distributable packages of a JavaFx
> Application?
> I have a Java 11 application which I build as a module. The distribution
> includes a "modules" folder with all dependencies in it, and a script to
> launch the module.
> This assembly works if I build it on the same machine as I am going to be
> running it on. However, I realized that depending on which build agent the
> assembly is going to be created, the platform specific javafx dependencies
> may not match the target assembly. For example, if the build agent is a
> linux build agent, the windows and mac assembly contains linux javafx
> runtime.
> Maven will always pull the platform-specific libraries of the system it is
> running on.
> This was not a problem when JavaFx was part of the JDK since the correct
> runtime libraries were installed on the system already.
> What is the correct way to create a windows or linux package in a build
> platform independent way?
> I found an article which showed how to force maven to include all platforms
> as dependencies, but then I have to add dependency on each transitive
> library. Sounds like a lot of trouble for a simple task.
> How do you guys package your apps for various platforms?
> *Nicolas Therrien*
> Senior Software Developer
> *[image:
> https://www.motorolasolutions.com/content/dam/msi/images/logos/corporate/msiemailsignature.png]*
> *o*: +1.819.931.2053

More information about the openjfx-dev mailing list