Hi all, recently I had some issue related to Launch4j enabled application. I did some digging and learned some useful stuff. The issue: running java -jar some_app.jar works just fine, but double click on some_app.exe does not work, the Launch4j enabled exe tells me that I need at least Java 1.8 in order to work correctly, but I have Java 21 already working fine.
Steps to reproduce:
* Install computer with Windows. I have Windows Server 2022 x64 10.0.20348.2762.
* Realize that Java is not included, do some Googleing and find out that Microsoft provides OpenJDK.
* Go to https://learn.microsoft.com/en-us/java/openjdk/download#openjdk-21 and download the .zip version.
* Unzip the archive to some random location. I didn't use program files nor app data directory, just some random directory where I keep unzipped software.
* Open the cmd.exe shell and put Java to the %PATH%. I added the bin directory, so I am able to run java.exe.
* Execute java -jar some_app.jar or java -jar some_app.exe, everything works fine.
* Execute some_app.exe, failure, the Launch4j wrapper tells me that I need at least Java 1.8 and then quits. But I already have Java 21 up and working.
I did some digging and learned that Launch4j searches for Java by various means. Most (all?) searching for Java is done in head_src\head.c file. It searches thru Registry, thru environment variables such as JREHOMEDIR and others. One of the env vars is PATH, it tries every sub element of %PATH% and appends bin\java.exe to it, hoping to locate the file. And this is my problem. I'm capable of running java.exe from command line just fine, but Launch4j is not able to find java.exe because it is searching for bin\java.exe instead.
Thus in this issue / bug report I would like to suggest to add more exhaustive search for java.exe in Launch4j. Please search for java.exe (or javaw.exe) in every directory mentioned in %PATH%. So the Launch4j enabled software would work in more cases. Thank you, Marek.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all, recently I had some issue related to Launch4j enabled application. I did some digging and learned some useful stuff. The issue: running
java -jar some_app.jar
works just fine, but double click onsome_app.exe
does not work, the Launch4j enabled exe tells me that I need at least Java 1.8 in order to work correctly, but I have Java 21 already working fine.Steps to reproduce:
* Install computer with Windows. I have Windows Server 2022 x64 10.0.20348.2762.
* Realize that Java is not included, do some Googleing and find out that Microsoft provides OpenJDK.
* Go to
https://learn.microsoft.com/en-us/java/openjdk/download#openjdk-21
and download the.zip
version.* Unzip the archive to some random location. I didn't use program files nor app data directory, just some random directory where I keep unzipped software.
* Open the
cmd.exe
shell and put Java to the%PATH%
. I added thebin
directory, so I am able to runjava.exe
.* Execute
java -jar some_app.jar
orjava -jar some_app.exe
, everything works fine.* Execute
some_app.exe
, failure, the Launch4j wrapper tells me that I need at least Java 1.8 and then quits. But I already have Java 21 up and working.I did some digging and learned that Launch4j searches for Java by various means. Most (all?) searching for Java is done in
head_src\head.c
file. It searches thru Registry, thru environment variables such asJREHOMEDIR
and others. One of the env vars isPATH
, it tries every sub element of%PATH%
and appendsbin\java.exe
to it, hoping to locate the file. And this is my problem. I'm capable of runningjava.exe
from command line just fine, but Launch4j is not able to findjava.exe
because it is searching forbin\java.exe
instead.Thus in this issue / bug report I would like to suggest to add more exhaustive search for
java.exe
in Launch4j. Please search forjava.exe
(orjavaw.exe
) in every directory mentioned in%PATH%
. So the Launch4j enabled software would work in more cases. Thank you, Marek.