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.
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
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).
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"
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
andbin
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!!!!
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:
In the xml file of launch4j i configure the jre like this:
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.
The only way I could bundle a JRE was to use Launch4J and Inno Setup Compiler.
First, create a 'jre6' folder (for example) in the same directory as your output file (.exe).
Then copy the JRE from your system into your jre6 folder.
Then you open Launch4J and set the 'Bundled JRE path' - just type in: jre6 . Then click the Build button (obviously, after you've entered all the other parameters - but the only value you need to enter on the 'JRE' tab itself is the 'Bundled JRE path' value.)
I would have expected that to work, but if move the .exe to a new location (so it is no longer co-located with your jre6 folder) you get the "This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted" error when you try to run the application...
I've been playing around with this all day and there was no way I could get Launch4J to include the JRE in the .exe file. Really poor in my opinion, as their documentation does not seem to allude to this issue at all.
So what I did to solve was to use Inno Setup Compiler. This app is used to wrap your .exe as a Windows Installer file. So I added a setting to ISC script that copies the JRE into the installer package. The line I added to the script (in the [Files] section) was:
...a bit of workaround, but it did the trick.
Repeat all the above steps, and you should be sorted.
ANSWER TAKEN FROM here..user1617737