Reputation: 2031
I have Launch4J on my computer and it's a great program. One of its features I'm interested in is the ability to bundle a JRE in the general .EXE file. However, I can't find any documentation that describes how to go about doing this.
How do I bundle a JRE with the EXE? Plus, where do I get a compact, portable JRE to run? The download links on Oracle are for the installer packages.
Upvotes: 97
Views: 121291
Reputation: 118
The mentioned answers above did not work for me. I am using JDK 20. What I did:
A simple folder view:
appFolder
|- myJdk
|- all contents from my jdk folder, installed on the machine. (The only folder I could remove was the jmods. All the rest were needed)
|- jar file
Upvotes: 1
Reputation: 361
A working example of using Launch4J to bundle a Java application with a specific JRE can be found at https://github.com/vZome/vzome/blob/master/desktop/platform/windows/README.md. This particular distribution is configured to require vZome to use the bundled JRE rather than any JRE found on the target platform.
Hope this helps.
Upvotes: -2
Reputation: 56
I have just done this. Above clearly describe the method for bundling jre.
Here, I just share an experience that I have struggled. If you want to create an installer exe after created wrapper exe by launch4j, pay attention to the file path for launch4j and jre. This is my path I used to solve my issues:
launch4j, bin/jre, resources/bin/jre.
launch4j, bin, and resources are at same level.
Upvotes: 0
Reputation: 221
I did the following and it worked for me using ver Launch4j 3.11:
In the Launch4j having set all the required options, then set the Bundled JRE path to "jre"
Upvotes: 22
Reputation: 7713
The same problem like you mate. No worries now. Its all solve with the maximum depth to solve future solution. Solution how you can bundle your JRE for your jar without the need that the user has to install java or not. Your java application will run.
lib
and bin
folder from your JRE folder to your project dist folderThe trick is you need to give the full path to the including javaw.exe.
Enjoy!!!!
Upvotes: 9
Reputation: 25149
After some attempts i finally get a workaround to bundle the jre in my application:
I package my app as a zip file with the following folders inside:
containerFolder
|- jre
|-bin (in bin there is java.exe)
|-lib
|- cfg (to save the user configuration, but it's not needed)
|- bin (my application with the .exe and the .jar and all the other stuff)
In the xml file of launch4j i configure the jre like this:
<jre>
<path>../jre</path>
<opt>-DgvSIG.confDir=../cfg</opt>
</jre>
The trick here is that the path is not to the java.exe file. The path to the jre is relative to the position of the .exe and it should point to one folder before the java.exe file
The jre folder i'm using is just a copy&paste from the jre folder installed on a windows system.
Upvotes: 105
Reputation: 4236
The jre can usually be found in your SDK folder. Yes the links online are installers, but once it installs, the JRE is now located on your local disk. Mine is located in
${jdk folder}\jre
The parts that you don't need from the JRE could probably be removed manually if you really wanted (I'm not sure whats available online).
Upvotes: -2