i am aware that there are many similar questions like this one, but i could not make it work with those solutions.
I am using Launch4J 3.50, and trying to run a exe using a bundled JRE, which is provided by adoptium https://adoptium.net/temurin/releases/?version=11
By starting the exe from a bat file, using SET Launch4j=debug option, i am able to generate this log file:
Version: 3.50
CmdLine: D:\MyApp.exe
JNI: No
WOW64: Yes
Working dir: D:\.
Requires JDK: Yes
Requires 64-Bit: No
Java min ver: 1.011.000_000
Java max ver: 1.011.900_900
JRE paths: service\adoptium
Check launcher: D:\service\adoptium\bin\javaw.exe (OK)
Check javac: D:\service\adoptium\bin\javac.exe (not found)
64-bit search: SOFTWARE\JavaSoft\Java Development Kit...
32-bit search: SOFTWARE\JavaSoft\Java Development Kit...
64-bit search: SOFTWARE\JavaSoft\JDK...
32-bit search: SOFTWARE\JavaSoft\JDK...
64-bit search: SOFTWARE\IBM\Java Development Kit...
32-bit search: SOFTWARE\IBM\Java Development Kit...
64-bit search: SOFTWARE\IBM\Java Development Kit...
32-bit search: SOFTWARE\IBM\Java Development Kit...
Error msg: This application requires a Java Runtime Environment 11.0.0 - 11.900.900
This is my root folder:
This is my service folder:
And this is my Launch4J xml configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>C:\Users\jhonnyD\Desktop\launch4j\service\jars\MyApp.jar</jar>
<outfile>.\MyApp.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl></downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<restartOnCrash>false</restartOnCrash>
<manifest></manifest>
<icon>C:\Users\jhonnyD\Desktop\launch4j\myIcon.ico</icon>
<classPath>
<mainClass>com.main.StartMyApp</mainClass>
<cp>C:\Users\jhonnyD\Desktop\launch4j\service\jars\lib\*</cp>
</classPath>
<jre>
<path>service/adoptium</path>
<requiresJdk>true</requiresJdk>
<requires64Bit>false</requires64Bit>
<minVersion>11.0.0</minVersion>
<maxVersion>11.900.900</maxVersion>
</jre>
</launch4jConfig>
When i run this on a computer that has java installed, the exe works. Clearly it is picking up the jre from the system. When i run this on a computer where java is missing, i am getting:
This application requires a Java Runtime Environment 11.0.0 - 11.900.900
The strange thing is that the log states that bundled javaw.exe is found:
Check launcher: D:\service\adoptium\bin\javaw.exe (OK)
Am i missing something here?
Seems like you need to change the option in tag <requiresJdk>
from true
to false
.
I've tested launch4j 3.50 just now on my app with similar config and it worked fine with this min config:
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>C:\launch4j-3.50-win32\service\jars\dvm.jar</jar>
<outfile>C:\launch4j-3.50-win32\dvm.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl></downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<restartOnCrash>false</restartOnCrash>
<manifest></manifest>
<icon></icon>
<jre>
<path>service/adoptium</path>
<requiresJdk>false</requiresJdk>
<requires64Bit>false</requires64Bit>
<minVersion></minVersion>
<maxVersion></maxVersion>
</jre>
</launch4jConfig>