Packaging JavaME Applications with the Antic Ant task

Steve Neal Development, Java Programming, Tool support 2 Comments

This article illustrates just how simple it is to correctly package a Java ME Midlet using Smartkey’s freely available Antic Ant task.

Packaging Midlets

Packaging Midlets can be a complex process. Firstly, there are requirements for two files to be created: a Jar and a Jad file. The Jar file will contain all of the classes and other resources that the application requires, and the Jad file will contain entries which describe the contents of the Jar. In both the Jar and the Jad files, there are a number of mandatory entries that must be made. Among other things, the manifest in the Jar must, for example, specify the application version and the Jad file must specify the exact size of the Jar file.

If any of the entries in either of these files is incorrect, then your application may not work on a some devices; and the only way to check that an incorrectly packaged application works on all devices is to test it on all devices. Very impractical – a far better solution, obviously, is to correctly package the application in the first place.

Antic is an Ant task that can be used in conjunction with any standard Ant release. Antic fills a gap in the standard Ant tasks’ functionality and provides capabilities for packaging Java ME applications. All other related Java ME build functionality can automated with the standard Ant tasks.

Using Antic in an Ant build files

A typical Antic entry in a build file might look like this:

<taskdef name="antic"

<target name="package" depends="compile">
<antic suiteName="Demo Suite"

<midlet name="First Midlet" classname="MessageMidlet"/>
<midlet name="Second Midlet" classname="DisplayMidlet"/>

<attribute name="message" value="Hello World!!!"/>

<fileset dir="${build}" includes="**/*"/>
<fileset dir="${images}" includes="*"/>

Above, we can see that before we can use Antic, we must use the Ant taskdef element to declare a new task that we will use in this build file; with this we must specify the name, class, and classpath for the task.

We then define an target named ‘package’. This target uses Antic to create a Jar file called ‘demo.jar’, and an associated Jad file called ‘demo.jad’. All mandatory entries for the Jar file’s manifest and the Jad file are specified at attributes on the Antic task.

Within the Antic task there are two of midlet elements to describe each midlet in the suite; in this particular example there are two, called ‘First Midlet’ and ‘Second Midlet’. Attributes can also be specified for the midlet suite, this is shown on the next line. The last elements within the Antic task are filesets; these specify the files that must be added to the Jar file; there must be at least one fileset element here.

If you’d like to use Antic to build your own J2ME applications, then go to our tools page where you can download the current release.

Comments 2

Leave a Reply

Your email address will not be published. Required fields are marked *