Java Launch4j

  1. Launch4j Java 11
  2. Java Launch4j Software

Convert jar to exe using Launch4J (Tutorial) Although wrapping a jar in an Exe file doesn’t make any sense as it can be extracted easily using tools like WinRAR, you can still avail the benefits of it if you want to deploy your application on a client-side machine. Apr 18, 2013 Convert JAR to EXE using Launch4J (Tutorial) Click on new Configuration menu. When a popup window appears saying discard changes, click on yes; Now Select the path to your output file (suppose you want to create an executable named project.exe in D: directory then your path to output file would be D: project.exe ). 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.

Cross-platform Java executable wrapper

Launch4j is a cross-platform tool for wrapping Java applications distributed as jars in lightweight Windows native executables. The executable can be configured to search for a certain JRE version or use a bundled one, and it's possible to set runtime options, like the initial/max heap size. The wrapper also provides better user experience through an application icon, a native pre-JRE splash screen, a custom process name, and a Java download page in case the appropriate JRE cannot be found.

Features

  • Launch4j wraps jars in Windows native executables and allows to run them like a regular Windows program. It's possible to wrap applications on Windows, Linux, Mac OS X and Solaris!
  • Also creates launchers for jars and class files without wrapping.
  • Supports executable jars and dynamic classpath resolution using environment variables and wildcards.
  • Doesn't extract the jar from the executable.
  • Custom application icon with multiple resolutions and color depths.
  • Native pre-JRE splash screen in BMP format shown until the Java application starts.
  • Process name as the executable filename to easily identify your application, initial priority and single aplication instance features.
  • Works with a bundled JRE or searches for newest Sun or IBM JRE / JDK in given version range.
  • Opens Java download page if an appropriate Java version cannot be found or a support website in case of an error.
  • Supports GUI and console apps.
  • Supports Vista manifests and XP visual style manifests.
  • Passes command line arguments, also supports constant arguments.
  • Allows to set the initial/max heap size also dynamically in percent of free memory.
  • JVM options: set system properties, tweak the garbage collection...
  • Runtime JVM options from an .l4j.ini file.
  • Runtime command line switches to change the compiled options.
  • Access to environment variables, the registry and executable file path through system properties.
  • Set environment variables.
  • Option to change current directory to the executable location.
  • The JRE's bin directory is appended to the Path environment variable.
  • Custom version information shown by Windows Explorer.
  • GUI and command line interface.
  • Build integration through an Ant task and a Maven Plugin.
  • Lightweight: 26 KB!
  • It's free and may be used for commercial purposes.
  • Includes a sample application and Ant script that automates the build process from Java sources to native executable.
  • The wrapped program works on all Windows platforms (98/Me/NT/2K/XP/Vista), Launch4j works on NT/2K/XP/Vista, Linux, Mac OS X (build on 10.4) and Sparc Solaris 8-10.

License

This program is free software licensed under the BSD license, the head subproject (the code which is attached to the wrapped jars) is licensed under the MIT license. Launch4j may be used for wrapping closed source, commercial applications.

Launch4j Java 11

Java Launch4j

Info

Running Launch4j on other Java enabled platforms is a matter of getting a binary version of MinGW binutils 2.15.90 (windres and ld only) for your system or compiling them. If you'll provide these, I'll be able to create a binary package available for download.

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.

Answers:

After some attempts i finally get a workaround to bundle the jre in my application:

Java

I package my app as a zip file with the following folders inside:

Java Launch4j

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.

Answers:

The only way I could bundle a JRE was to use Launch4J and Inno Setup Compiler.

Interview

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.

Java launch4j software

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

Java Launch4j Software

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

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