### Distribute an Application

When compiling in Release Mode (Hint: ensure to set Release Mode in the IDE dropdown box) a Jar file is created in the Objects folder.
This Jar file contains all code, required libraries and assets (from the files folder).
The compiled jar file can be executed, if Java is setup correctly on your Windows system:
• by double clicking on the Jar file or
• by invoking from the command line java -jar yourappname.jar
To create an runtime executable, following options (there might be more).
B4J Packager
This is a small utility that uses the javapackager to create a single file installer for Mac or Windows, that
includes the app files and the Java runtime.
Reference: http://www.b4x.com/android/forum/threads/ui-apps-packaging-self-contained-installers.56854/#content
The packed application has a size of ~40MB.
Launch4J
The software Launch4J - Cross-platform Java executable wrapper - is an other option to use.
Information: http://launch4j.sourceforge.net
Documentation: http://launch4j.sourceforge.net/docs.html
Get Help: http://sourceforge.net/projects/launch4j/forums/forum/332684.
Launch4J Hints
For each wrapped application, create a Launch4J configuration file.
After starting Launch4J, reload the configuration file.
When using Java 8 set the
• Min version to 1.8.0
• Max version to the latest, like 1.8.0_5
To get the jre maxVersion, use from the commandline: java -version
Enter from the Output Example 1.8.0_45 as the jre maxVersion
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) Client VM (build 25.45-b02, mixed mode)
Launch4J Configuration File Example
Launch4J configuration file example for the authors B4J example application B4JHowTo.
The xml outline might have changed depending on the latest version of Launch4J.
The configuration file is placed in the Objects folder (holding the Jar, Database, Ini-File etc.).
The configuration file extention must be set to xml.
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>C:\Daten\b4j\opensource\b4jhowto\Objects\B4JHowTo.jar</jar>
<outfile>C:\Daten\b4j\opensource\b4jhowto\Objects\B4JHowTo.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir></chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<manifest></manifest>
<icon></icon>
<jre>
<path>c:\Program Files (x86)\Java\jre7\bin\</path>
<bundledJre64Bit>false</bundledJre64Bit>
<minVersion>1.7.0_40</minVersion>
<maxVersion>1.7.0_55</maxVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>v20140416</txtFileVersion>
<fileDescription>B4J HowTo Offline Reader</fileDescription>
<copyright>Copyright (c) 2014 by Robert W.B. Linn, Pinneberg, Germany</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>v20140516</txtProductVersion>
<productName>B4JHowTo</productName>
<companyName>Robert W.B. Linn</companyName>
<internalName>b4jHowTo</internalName>
<originalFilename>b4jHowTo.exe</originalFilename>
</launch4jConfig>

Changed: , Category: Application, File: T6C159M1156.htm, ID: 1156