Search code examples
javamavenintellij-ideajavafxjpackage

Jpackage with ControlsFX


I’m having some issues including Controlsfx when using Jpackage.

I have set up a project in IntelliJ with JavaFX using a Archetype from Maven Central. Works fine with JavaFX in IntelliJ. I can package it with Maven (from IntelliJ) and use JPackage for making an exe-installer, that also works fine. I’m using this command with JPackage:

jpackage --input C:\...\target --add-modules javafx.controls --module-path C:\...\openjfx-20.0.1_windows-x64_bin-jmods\javafx-jmods-20.0.1 --module-path --win-console --dest c:\outputs --main-jar tests-1.0-SNAPSHOT.jar --main-class tests.App

Now I want to incorporate ControlsFX so I download the ControlsFX .JAR from Maven: https://mvnrepository.com/artifact/org.controlsfx/controlsfx/11.1.2IntelliJ In IntelliJ I add it as a Module. All fine, I wan use ControlsFX in my project.

Now I want to make an exe-installer (like above without ControlsFX) so I add ControlsFX to my JPackage command:

jpackage --input C:\...\target --add-modules javafx.controls,controlsfx --module-path C:\...\openjfx-20.0.1_windows-x64_bin-jmods\javafx-jmods-20.0.1 --module-path C:\..\controlsfx --win-console --dest c:\test --main-jar tests-1.0-SNAPSHOT.jar --main-class tests.App

When running the command I get this:

java.lang.module.FindException: Module controlsfx not found

I know my issue is related to the command I pass to JPackage but cant figure out what is.


Solution

  • As mentioned by @Slaw in comments below, you have used the wrong module name. You can confirm the module name of a jar by viewing the module definition. This tells you the name of the module to use with jpackage eg org.controlsfx.controls or will print No module descriptor found. Derived automatic module. if a non module jar:

    jar --file=controlsfx.jar --describe-module
    org.controlsfx.controls@11.1.2 jar:file:///c:/dev/mods/controlsfx.jar!/module-info.class
    ... plus details of exports
    

    The jpackage command will use jlink internally to build a runtime image that contains all the modules listed:

    jpackage --input myinput --add-modules javafx.controls,org.controlsfx.controls --module-path c:\xyz...\javafx-jmods-NN --module-path c:\abc...\controlsfx.jar  --dest myoutput {otherargs}
    

    After installation you can check which modules are in the installed runtime with:

     C:\Program Files\XYZ\runtime\bin\java --list-modules
     ...
     javafx.controls@somever
     ...
     org.controlsfx.controls@somever
    

    Alternatively you can use a jar (module or non module) with jpackage by copying the jar into your target release structure somewhere under the --input directory. Then it will be picked up as a classpath jar dependency (inside the release directories) rather than as a module dependency (inside the runtime image as above).

    You can check if a jar was added as as classpath dependency by looking at the generated {launcher}.cfg, it should contain a line:

     app.classpath=$APPDIR\whateverplaceunder--input.dir\controlsfx.jar