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 you then 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 (ISC). This app is used to wrap your .exe as a Windows Installer file. So I added a setting to the ISC script that copies the JRE into the installer package. The line I added to the script (in the [Files]
section) was:
Source: "M:NetbeansMyAppjre6*"; DestDir: "{app}jre6"; Flags: recursesubdirs createallsubdirs
...a bit of workaround, but it did the trick.
Repeat all the above steps, and you should be sorted.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…