javajsoupjpackage

Problems creating .EXE with jpackage -problems with jsoup when program is called by EXE, but OK in Intellij


I created with Intellij an application that uses Javafx, Lucene, JDOM and other libraries. On Intellij everything compiled and runs successfully. Now I am about to create an runtime image for Windows using jpackage. The problem is now to add the libraries. For Javafx and Lucene I have module-jars. These can be added easily. For JDOM and the other libraries I have only ordinary jar-files without module-info.class. There I am getting the error from jpackage:

jpackage
  --type exe
  --app-version 1.0
  --module-path %PATH_TO_FX_MOD%
  --module-path %PATH_TO_LUCENE_MOD%
  --module-path %PATH_TO_JDOM_MOD%
  --add-modules javafx.controls,javafx.fxml,javafx.base,javafx.graphics,javafx.media,javafx.swing,javafx.web,org.apache.lucene.core,org.apache.lucene.queryparser,jdom
  --copyright "Susanne Krause"
  --description "Recipe administration tool with creation, import and administration of recipes"
  --name "Susannes Rezeptbuch"
  --vendor "Susanne Krause"
  --verbose
  --win-dir-chooser
  --win-menu
  --win-shortcut
  --dest C:\Users\baerbel\Rezeptbuch_compiledir\2022.0.1\bin
  --input C:\Users\baerbel\Rezeptbuch_compiledir\2022.0.1\jar
  --icon C:\Users\baerbel\Rezeptbuch_compiledir\susannesrezeptbuch.png
  --main-jar SusannesRezeptbuch.jar
  --main-class com.workingelectrons.susannesrezeptbuch.SusannesRezeptbuch

This is the message from jpackage:

jdk.jpackage.internal.PackagerException: jlink failed with: Error: Unable to derive module descriptor for C:\Program Files\Java\jdom-2.0.6\jdom-2.0.6-contrib.jar
java.lang.module.FindException: Unable to derive module descriptor for C:\Program Files\Java\jdom-2.0.6\jdom-2.0.6-contrib.jar

What can I do to add these kind of modules to my application ?


Solution

  • You will only be able to create a jlink runtime image from the modules - omit the non-module jars from the module path. I haven't checked, but you may also need to merge the module path as one argument --module-path %PATH_TO_FX_MOD%;%PATH_TO_LUCENE_MOD%;%PATH_TO_JDOM_MOD%

    You should include the non-module jars in your --input directory structure, then they will be included in the generated installation and also added as class-path elements for the generated EXE files.

    For example if you set up folder app-image\jars with remaining non-module jars and used jpackage --input app-image ..., then after installation you should see the class-path jars in your release structure, and each added to each \Program Files\YourApp\yourlauncher.cfg file:

    [Application]
    app.classpath=$APPDIR\jars\some.jar
    app.classpath=...
    

    If you are still have problems from the generated EXE note the problems mentioned here and edit your question with details: