1.4.2,  2.0.RC3

How to wrap your application

Launch4j wraps only executable jars, which aren't very difficult to create. Package your application in a jar file and include a manifest with the Main-Class attribute defined. In order to use external jars, you must also define the Class-Path attribute. Create a configuration file and run launch4j (launch4j my_application.cfg). It's a good idea to run it inside a console window to see the output. If the configuration file is invalid, launch4j will provide useful information that will help you fix the problem. If everything goes fine, the output exe will be created and ready to run. All information provided in the config file is stored in the executable, so you don't need it to run the application.

Faster way...

Create the configuration file and let Ant do the rest (SimpleApp/build.xml).

Configuration file (1.x)

Bold elements are required.
header headfile.bin
jar application.jar
outfile application.exe
jrepath ../jre
and/or
javamin version
javamax version    // optional, use only in combination with javamin.
jvmArgs args
jarArgs args
chdir true|false
setProcName true|false
errTitle application_name
icon icon.ico
splash splash.bmp
waitfor beginning_of_application_title
splashTimeout seconds
splashTimeoutErr true|false
stayAlive true|false

Configuration details

header
Optional, defaults to guihead.bin. Standard headers are: guihead.bin and consolehead.bin, you can also specify your own.
Header
App  type
Launcher
Splash screen Wait for the application to close
guihead.bin
GUI
javaw
yes
wrapper waits only if stayAlive is set to true, otherwise it terminates immediately or after closing the splash screen.
consolehead.bin
console
java
no
always waits and returns application's exit code.

jrepath, javamin/javamax
The jrepath property is used to specify the path (usually relative) of a JRE, note that this path is not checked until the actual application execution. If you'd like the wrapper to search for a JRE (public or SDK private) use the javamin property, you may also specify the javamax to prevent it from using higher Java versions. Launch4j will always use the highest version available (in the min/max range of course). You can also combine these properties to change the startup process...
jrepath
Run if bundled JRE and javaw.exe are present, otherwise stop with error.
jrepath + javamin [+ javamax]
Use bundled JRE first, if it cannot be located search for Java, if that fails display error message and open the Java download page.
javamin [+ javamax]
Search for Java, if an appropriate version cannot be found display error message and open the Java download page.
jvmArgs
Optional, accepts everything you would normally pass to java/javaw launcher: assertion options, system properties and X options.
jarArgs
Optional, constant command line arguments.
chdir
Optional, defaults to false. Change current directory to exe location. Set this property to true, if you have resources outside the jar or want to use a bundled JRE which location is relative to the executable.
setProcName
Optional, defaults to false. Set the process name as the executable filename. Creates a temporary file in launch4j-tmp directory inside the used JRE. These files are deleted by any launch4j wrapped application, which sets the process name and uses the same JRE. The removal takes place when the application starts, so at least one copy of this file will always be present.
errTitle
Optional, sets the title of the error message box that's displayed if Java cannot be found for instance. This usually should contain the name of your application. The console header prefixes error messages with this property (myapp: error...)
icon
Accepted file format: ICO
The first icon is used and rescaled when needed.
splash
Accepted file format: BMP
Ignored by consolehead.bin
waitfor
Optional. Specifies the beginning of the application title, used to determine when the splash screen is to be closed. Don't include version numbers or other information (My Application v1.20, My App - Program setup...). If omitted, the splash screen will close on timeout.
Ignored by consolehead.bin
splashTimeout
Optional, defaults to 60. Number of seconds after which the splash screen must close. Splash timeout may cause an error depending on splashTimeoutErr property. Ignored by consolehead.bin
splashTimeoutErr
Optional, defaults to true. True signals an error on splash timeout, false closes the splash screen quietly.
Ignored by consolehead.bin
stayAlive
Optional, defaults to false in guihead.bin / always true in consolehead.bin. When enabled the launcher waits for the Java application to finish and returns it's exit code.

Example configurations

jar paint2\paint2.jar
outfile paint2\paint2.exe
javamin 1.4.0
javamax 1.4.2
icon paint2\paint2.ico
errTitle Paint2 Error
splash paint2\paint2.bmp
waitfor Paint2
splashTimeout 45
chdir true
setProcName true
header consolehead.bin
jar dist\ConsoleApp.jar
outfile dist\ConsoleApp.exe
jrepath ..\jre
javamin 1.4.2
icon l4j\ConsoleApp.ico
chdir true
setProcName true
errTitle ConsoleApp
jvmArgs -Xloggc:gclog.txt