How to bind JRE with EXE for Java application? Launch4j says: "Runtime is missing or corrupt."

I am new to Java programming, but I am generally familiar with how everything works. I would like to be able to add both the jar file and the jre to the windows (exe) executable so that when it is distributed, the client should not have the JRE installed. Which program should I use?

I have launch4j and it seems to be doing exactly what I want, but when I try to launch the application, I get: "This application was configured to use the associated Java runtime, but the runtime is missing or corrupt."

I want my application to be just executable exe, not an installer. At least can someone show me how to properly associate JRE with launch4j?

+25
java exe jar launch4j
Dec 21
source share
9 answers

If you need one EXE, check:

HOWTO: Create One EXE from Your Java Application

Note. . The above article mainly discusses free tools (7-Zip and ResEdit.) Using Excelsior JET is strictly optional. If you don’t need a true native EXE code, add a private JRE and you will achieve the goal using only these free tools.

+7
Dec 29 '12 at 9:27
source share

The only way to bind the JRE is 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 pool in the bundle - just enter jre6 . Then click the Create button (obviously after entering all the other parameters), but the only value you need to enter on the JRE tab is the path to the JRE pool .)

I would expect this to work, but if you then move the.exe file to a new location (so that it no longer resides with your jre6 folder), you get this application that was configured to use the associated Java Runtime Environment, but in there is no runtime or a bug is damaged when trying to start the application ...

I played all day with this 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 what I did to decide was to use the Inno Setup (ISC) compiler. This application is used to transfer your.exe as a Windows Installer file. Therefore, I added a parameter to the ISC script that copies the JRE to the installer package. The line that I added to the script (in the [Files] section) was:

 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.

+33
Mar 25 '13 at 16:44
source share

I have never used the Launch4J product, good luck setting it up properly.

It looks like you could go to the Sourceforge discussion forum for other tips here

Other offers:

Most of the products I have seen from IBM (Websphere) and Oracle simply extract the JRE in the installation directory and configure the launch command to use the installed JRE. In essence, the JRE and your jar file will be installed in one shot.

Usually, the installation exe checks to see if it is already installed, and skips this step if it already found it there. This is useful for updating only the jar file.

The presence of a local installation also solves the problem of a user installing their own JRE, which may be incompatible or contain errors. So you are dealing with a well-known version of the JRE.

The excelsior route is fine if you do not have a graphical component for your application (it was time, this restriction may have changed). There are other limitations, but you probably just better just distribute the JRE with the code in one executable installer.

+1
Dec 21 '12 at 21:17
source share

It seems you need your own code compiler. These compilers produce native code that does not require a JRE.

Check out this article - https://www.excelsior-usa.com/articles/java-to-exe.html#aot .

0
Dec 21 '12 at 21:05
source share

Its easy to bundle jre in launch4j ..

just copy jre to the same output folder

In the jquery bundle environment text box, just specify the jre folder

In the text box of the environment variable (presented on the same page below), give while bin

Then create an exe .. It works as expected without jre in the machine.

thanks

0
Feb 05 '18 at 11:47
source share

Complete JRE Solution for Inno Installation

In order to implement a related JRE solution with the jar application, I created the Inno Setup script, which:

1) copies the JRE to the installation exe

2) execute the equivalent of a terminal command: java -jar myjar.jar using the associated JRE

First I copy the JRE:

 #define MyJREPath "C:\Program Files\Java\jre1.8.0_191" [Files] Source: "{#MyJREPath}\*"; DestDir: "{app}\runtime\jre\"; \ Flags: ignoreversion recursesubdirs createallsubdirs; 

I adhere to the directory structure agreement shown here: https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html

To run the java -jar equivalent of myjar.jar:

 [Run] Filename: "{app}\runtime\jre\bin\javaw.exe"; Parameters: " -jar myjar.jar"; \ WorkingDir: "{app}\app\"; \ Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; \ Flags: postinstall skipifsilent 

(nb java.exe works with the terminal, and javaw.exe works without the terminal)

The shortcut on the desktop should have the correct file name, parameters and working directory:

 [Icons] Name: "{commondesktop}\{#MyAppName}"; \ IconFilename: "{app}\app\{#MyAppIcoName}"; \ Filename: "{app}\runtime\jre\bin\javaw.exe"; \ Parameters: " -jar myjar.jar"; \ WorkingDir: "{app}\app\"; \ Tasks: desktopicon [Tasks] Name: "desktopicon"; \ Description: "{cm:CreateDesktopIcon}"; \ GroupDescription: "{cm:AdditionalIcons}"; \ Flags: unchecked 

To freeze the cake so that my script processes both related JREs and no related parameters, I use the preprocessor IF statement (duplicated in each section of the script) to check if the script has an empty MyJREPath or not. If MyJREPath is not empty and therefore requires a comprehensive JRE solution, I use the above encoding; alternatively, if a batch solution is not required, then I use the more β€œnormal” coding shown in the Inno installation examples or created by their wizard. Here is the IF expression:

 #if MyJREPath != "" ; bundled JRE required #else ; bundled JRE not required #endif 

Here, most of my script is compiled:

  ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! ; some more #defines here #define MyAppExeName "javaw.exe" #define MyJREPath "C:\Program Files\Java\jre1.8.0_191" ;#define MyJREPath "" [Setup] ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppId=XXXXXXXXXX AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} DefaultGroupName={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyDefaultDirName} DisableProgramGroupPage=yes LicenseFile={#MyInnoSetupDir}\system\{#MyLicenseFile} OutputDir={#MyInnoSetupDir} #if MyJREPath != "" ; run app with bundled JRE OutputBaseFilename={#MyAppName}-{#MyAppVersion}-bundledJRE-setup #else ; run app without bundled JRE OutputBaseFilename={#MyAppName}-{#MyAppVersion}-setup #endif SetupIconFile={#MyInnoSetupDir}\{#MyAppIcoName} Compression=lzma SolidCompression=yes AppComments={#MyAppName} AppCopyright={#MyAppCopyright} UninstallDisplayIcon={#MyInnoSetupDir}\{#MyAppIcoName} UninstallDisplayName={#MyAppName} WizardImageStretch=No WizardSmallImageFile={#MyInnoSetupDir}\{#MyAppBmpName} [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" ;Name: "german"; MessagesFile: "compiler:Languages\German.isl" [Tasks] Name: "desktopicon"; \ Description: "{cm:CreateDesktopIcon}"; \ GroupDescription: "{cm:AdditionalIcons}"; \ Flags: unchecked Name: "quicklaunchicon"; \ Description: "{cm:CreateQuickLaunchIcon}"; \ GroupDescription: "{cm:AdditionalIcons}"; \ Flags: unchecked; OnlyBelowVersion: 0,6.1 [Files] ; bundle JRE if required #if MyJREPath != "" Source: "{#MyJREPath}\*"; DestDir: "{app}\runtime\jre\"; \ Flags: ignoreversion recursesubdirs createallsubdirs; #endif ; copy jar and all files Source: "{#MyInnoSetupDir}\*"; DestDir: "{app}\app\"; \ Flags: ignoreversion recursesubdirs createallsubdirs [Icons] #if MyJREPath != "" ; set up icons with bundled JRE Name: "{commonprograms}\{#MyAppName}"; \ IconFilename: "{app}\app\{#MyAppIcoName}"; \ Filename: "{app}\runtime\jre\bin\{#MyAppExeName}"; \ Parameters: " -jar {#MyJarName}"; \ WorkingDir: "{app}\app\" Name: "{commondesktop}\{#MyAppName}"; \ IconFilename: "{app}\app\{#MyAppIcoName}"; \ Filename: "{app}\runtime\jre\bin\{#MyAppExeName}"; \ Parameters: " -jar {#MyJarName}"; \ WorkingDir: "{app}\app\"; \ Tasks: desktopicon Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; \ IconFilename: "{app}\app\{#MyAppIcoName}"; \ Filename: "{app}\runtime\jre\bin\{#MyAppExeName}"; \ Parameters: " -jar {#MyJarName}"; \ WorkingDir: "{app}\app\"; \ Tasks: quicklaunchicon #else ; set up icons without bundled JRE Name: "{commonprograms}\{#MyAppName}"; \ IconFilename: "{app}\app\{#MyAppIcoName}"; \ Filename: "{app}\app\{#MyJarName}"; \ WorkingDir: "{app}\app\" Name: "{commondesktop}\{#MyAppName}"; \ IconFilename: "{app}\app\{#MyAppIcoName}"; \ Filename: "{app}\app\{#MyJarName}"; \ WorkingDir: "{app}\app\"; \ Tasks: desktopicon Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; \ IconFilename: "{app}\app\{#MyAppIcoName}"; \ Filename: "{app}\app\{#MyJarName}"; \ WorkingDir: "{app}\app\"; \ Tasks: quicklaunchicon #endif [Run] #if MyJREPath != "" ; run app with bundled JRE Filename: "{app}\runtime\jre\bin\{#MyAppExeName}"; Parameters: " -jar {#MyJarName}"; \ WorkingDir: "{app}\app\"; \ Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; \ Flags: postinstall skipifsilent #else ; run app without bundled JRE Filename: "{app}\app\{#MyJarName}"; \ WorkingDir: "{app}\app\"; \ Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; \ Flags: shellexec postinstall skipifsilent #endif 

Hope this helps.

0
Dec 13 '18 at 21:28
source share

An easy way to package jre in exe, which is packaged in lanch4j, is to use wrap.

 warp-packer --arch windows-x64 --input_dir mycrt --exec run.bat --output single.exe 

and then stop cmd windows when starting exe.

 editbin /subsystem:windows 

Warp : https://github.com/dgiagio/warp

editbin : installed VS

Demo version:

enter image description here

enter image description here

0
Apr 13 '19 at 6:13
source share

What you are asking for is not easy to do (if at all possible). If I were you, I would consider creating a JAR executable:

java eclipse create an executable jar

Another option is to use Java Web Start. It was assumed that you are using a modern browser, JNLP will automatically prompt the user to install the correct version of Java.

http://docs.oracle.com/javase/tutorial/deployment/webstart/index.html

-2
Dec 21 '12 at 20:12
source share

There are several reasons why start4j is not working properly. one of the reasons:

1) the user does not start the application as an administrator

2) The user has incorrectly configured the icon image. must strictly .ico

-3
May 15 '14 at 2:46
source share



All Articles