It is the aim of the Ant-4-ME project to to develop a suite of tasks, for use with the Apache ANT build tool, to aid developers to build apps for J2ME (Micro Edition Java) devices. Primarily these will be aimed at developers working with MIDP/CLDC but it is hoped to expand the suite to facilitate other Micro Edition profiles and configurations.

There are a number of detailed steps involved in building a J2ME app from its source code into the binaries that could be executed on a J2ME device. These tasks can be quite laborious if done by hand and are ripe for automation by a tool such as Ant.

To begin the source for the suites applications (MIDlets) must be compiled and the resulting class files must then undergo a preverification process that verifies that the classes are J2ME compliant. J2ME is a subset of J2SE, classes compiled for J2ME will run unchanged in J2SE the reverse is not true however. The preverification step verifies that no J2SE code has been used in the MIDlet and it marks each compliant class' methods with stack map attributes to mark them as being preverified. Suites containing classes without these stack maps are rejected.

After preverification the classes must be jarred up and two documents generated that describe the suite, a JAR Manifest and a JAD (Java Appliation Descriptor). The Manifest details the contents of the Jar and lists a number of properties of the suite such as the MIDlets it contains. The JAD is downloaded to a device ahead of the acutal application JAR. It contains the same information mandatory for the Manifest and other information such as the size of the app JAR, URIs for download & info, vendor info and application parameters.

J2ME devices are by nature constrained for resources therefore to help conserve the application space available, and in many cases shrink your app sufficiently to beat the max app size constraints of many devices (64k max is not unheard of!), it may be necessary to obfuscate the class files. Of course this gives the added feature of protecting you code from reverse engineering.

Currently ANT-4-ME does the all of the above using predefined tasks for Ant leveraging the power of this widely used world class build tool. The obfuscation is achieved utilizing the Retroguard open-source Java obfuscator. In an effort to further decrease app sizes it contains a task that examines the class dependencies of the app and includes the minimal subset of classes required in the Jar. By this it is meant that if a suite uses a library with 10 classes but only 2 classes are used, then only the two classes (and any classes they are dependant on) will be placed in the distribution jar.

Current Feature list:

  • Tasks for Compilation and Preverification
  • Tasks to generate Manifest & JAD files
  • Tasks to determine minimal dependency set
  • Obfuscator support
  • Integration with the Eclipse IDE
  • Future features and enhancements:

  • Tasks to allow the integration of other Obfuscators commercial and opensource
  • Tasks to aid with jar signing
  • Tasks to modify compiled classes to remove unused & dead code.
  • Tasks to optimize application resources e.g. optimize png images
  • Other proposals shall be considered from iterested individuals willing to contribute to the project.


    These are some useful links for getting started with J2ME Development Apache ANT - Part of the Apache Jakarta Project.Java 2 Platform Micro Edition, Wireless Toolkit.The Eclipse Project. (Without doubt the finest Java IDE).Retroguard Java Bytecode Obfuscator.Lots of J2ME resource links.