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?