0

I am developing a Java application and distribute it with packaging with jpackage on Windows. I am using the following jpackage command to create the whole application image:

jpackage --java-options '-splash:$APPDIR/splash.png' --type app-image -n AppName -i jar --main-jar myApp.jar -d output --icon icon.ico

The images is created and has the following structure:

appName\
  AppName.exe
  icon.ico
  app\
    myApp.jar
    myApp.cfg
    some more data files
  runtime\
    bin\
    conf\
    legal\
    lib\
    release

If no other JDK/JRE is installed on the system, the application starts fine when clicking AppName.exe. However if a user has installed a JDK on the system for development or a JRE for another program where JAVA_HOME is set, and java.exe is on the path, then that Java environment is used to execute the program. Then, depending on the Java version, my application starts or does not start or odd errors are displayed. The packaged runtime is ignored.

One solution is to remove JAVA_HOME from the system variables, and remove java.exe from the path. But that is cumbersome for users and may cause problems for other applications on the system.

How can I use jpackage in such a way that during execution the use of the packaged runtime is enforced?

ndbd
  • 2,417
  • 3
  • 23
  • 32
  • I can not reproduce this issue with JDK 18.0.1. Even if I have another version of Java on the PATH, the application still picks up the runtime from the app image when launching through the launcher. (try e.g. making a main class that prints out the `java.home` system property, or the result of `Runtime.version()`). – Jorn Vernee Jul 22 '22 at 13:01
  • Which version of the JDK/jpackage are you using to make the app image? – Jorn Vernee Jul 22 '22 at 13:02
  • I am on openjdk 15 2020-09-15, (Adopt Open JDK, (build 15+36). I will try a newer JDK and report back – ndbd Jul 22 '22 at 18:41

0 Answers0