How to associate JRE with Launch4j?

I have Launch4J on my computer and this is a great program. One of its features that I'm interested in is the ability to combine the JRE into a common .EXE file. However, I cannot find documentation describing how to do this.

How to associate JRE with EXE? Plus, where can I get a compact portable JRE? Download links for Oracle are for installer packages.

+66
java exe portability launch4j
Aug 15 2018-11-21T00:
source share
6 answers

After some attempts, I finally get a workaround for jre binding in my application:

I will pack my application 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 not needed) |- bin (my application with the .exe and the .jar and all the other stuff) 

In the xml file of launch4j, I configure jre as follows:

 <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 jre is relative to the .exe position and should point to the same folder in front of the java.exe file.

The jre folder I use is just a copy and paste from the jre folder installed on Windows.

+71
Sep 28 '11 at 10:50
source share

The only way I could bind the JRE was to use Launch4J and the 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 to the jre6 folder.

Then you open Launch4J and install the "JRE Bound Path" - just type: jre6. Then click on the “Create” button (obviously after entering all the other parameters), but the only value you need to enter on the “JRE” tab is the value “Associated JRE value.”)

I would expect this to work, but if you move .exe to a new location (so that it no longer resides with your jre6 folder), you will get "This application has been configured to use the unified Java Runtime Environment but is missing or corrupt at runtime An error occurred while trying to start the application ...

I play with this all day and I could not get Launch4J to include the JRE in the .exe file. In fact, I believe that they are poor, as their documentation does not seem to refer to this problem at all.

So, I decided to allow the use of the Inno Setup compiler. This application is used to transfer your .exe as a Windows Installer file. Therefore, I added an ISC script parameter that copies the JRE to the installer package. The line I added to the script (in the [Files] section):

 Source: "M:\Netbeans\MyApp\jre6\*"; DestDir: "{app}\jre6\"; Flags: recursesubdirs createallsubdirs 

... a bit of a workaround, but he did the trick.

Repeat all the above steps and you should be sorted.

ANSWERS FROM here ..user1617737

+10
May 15 '14 at 2:49
source share

Same problem as you, buddy. Do not worry now. Everything is solved with maximum depth to decide the future decision. Deciding how you can link your JRE to your jar without the need for the user to install Java or not. Your Java application will be launched.

  1. Copy the lib and bin folder from the JRE folder to the dist folder of your project

jar to exe conversion

  1. Open launch4j and enter the following settings. enter image description here

The trick is that you need to specify the full path to the inclusive javaw.exe.

Enjoy!!!!

+5
Jan 03 '18 at 11:01
source share

I did the following and it worked for me using version of Launch4j 3.11:

  1. A new folder has been created for my application (called, for example, MyApp).
  2. I copied the jar file from the dist folder of the java project in MyApp along with the lib folder.
  3. A folder named jre has been created in the folder of my MyApp application, so now the MyApp folder contains:
    • Myapp.jar
    • lib <are the libraries needed for my Java application.
    • Jre
  4. I copied the bin and lib folders from the java jre folder (C: \ Program Files (x86) \ Java \ jre7) to MyApp \ jre
  5. In Launch4j, having set all the necessary parameters, then set the path to "jre" for Bundled JRE

    Launch4j JRE options

  6. Make sure that "Use only private JDK runtimes" is selected in the search options.
+3
Mar 29 '18 at 9:59
source share

I just did it. Clearly describe the JRE configuration method above.

Here I just share the experience that I struggled with. If you want to create an exe installation program after the created exe shell using launch4j, pay attention to the file path for launch4j and jre. This is my path that I used to solve my problems:

launch4j, bin / jre, resources / bin / jre.

launch4j, bin and resources are on the same level.

0
Jun 21 '19 at 21:23
source share

Typically, the jre file can be found in the SDK folder. Yes, links on the Internet are installers, but after installation, the JRE is now located on your local drive. Mine is in

 ${jdk folder}\jre 

Parts that you do not need from the JRE can probably be removed manually if you really want to (I'm not sure what is available on the Internet).

-one
Aug 15 2018-11-11T00:
source share



All Articles