Java Launch4j

  1. Launch4j Java 11
  2. Launch4j Java_home

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.

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. In launch4j go to the classpath tab. Tick the custom classpath field. In the edit field, enter the full path of each jar you want included and press accept. When finished type just the name of the main class into the separate field (ie MyProg). All the jars will now be included in the exe. Dropped Launch4j source and based on artifacts from Maven Central, see #8(././issues/8) uses the latest version of Launch4j (3.4.0) at least Java 1.7 is required; FAQ. Q: I cannot build my project because dsol-xml dependency is missing? A: Add this repository to your /.m2/settings.xml.

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.

Answers:
Java

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.

Java Launch4j
Answers:

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.

Launch4j

Repeat all the above steps, and you should be sorted.

ANSWER TAKEN FROM here..user1617737

Answers:

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

Launch4j

Launch4j Java 11

Java

Launch4j Java_home

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).