exe4j Help

Using Exe4j With Ant


For integrating exe4j with your Ant script, use the exe4j task that is provided in {exe4j installation directory}/bin/ant.jar and set the projectfile parameter to the exe4j config file that you want to build.

To make the exe4j task available to Ant, you must first insert a taskdef element that tells Ant where to find the task definition. Here is an example of using the task in an Ant build file:

<taskdef name="exe4j"
         classname="com.exe4j.Exe4JTask"
         classpath="C:\Program Files\exe4j\bin\ant.jar"/>

<target name="launcher">
  <exe4j projectfile="myapp.exe4j"/>
</target>

The taskdef definition must occur only once per ant-build file and can appear anywhere on the top level below the project element.

Note that it is not possible to copy the ant.jar archive to the lib folder of your ant distribution. You have to reference a full installation of exe4j in the task definition.

Task properties

The exe4j task supports the following parameters:

AttributeDescriptionRequired
projectfileThe exe4j config file for the launcher that should be generated.Yes
verbose Corresponds to the --verbose command line option. Either true or false. No, verbose and quiet cannot both be true
quiet Corresponds to the --quiet command line option. Either true or false.
failOnWarning Corresponds to the --fail-on-warning command line option. Either true or false.
test Corresponds to the --test command line option. Either true or false. No
release Corresponds to the --release command line option. Enter a version number like "3.1.2". The version number may only contain numbers and dots. No
requirelicense Corresponds to the --require-license command line option. No
license Corresponds to the --license command line option. If the license has not been configured yet, you can set the license key with this attribute. No
destination Corresponds to the --destination command line option. Enter a directory where the generated launcher should be placed. No

Modifying project files at build time

To customize aspects of the exe4j build that cannot be overridden with he above parameters, you can add appropriate tokens in the config file and use the copy task with a nested filterset element. For example, if the main class in

<java mainClass="com.mycorp.MyApp" ...

should by dynamically adjusted by Ant, just edit the line to

<java mainClass="@MAIN_CLASS@" ...

and copy the template config file (here myapp_template.exe4j) with

<copy tofile="myapp.exe4j" file="myapp_template.exe4j">
  <filterset>
    <filter token="MAIN_CLASS" value="com.mycorp.MyOtherApp" />
  </filterset>
</copy>

before running the exe4j compiler as before.