Posted by: Marek | March 13, 2009

Building a Java ME application with Maven

Building a Java ME application with Maven is not trivial, but doable. The following items need to be taken into consideration.

  1. CLDC and MIDP APIs need to be added to the project classpath. This is pretty straightforward:


















  2. The compiler needs to be set up to use the Java 1.3 class format and only use CLDC and MIDP APIs in the classpath. Again, this is pretty straightforward:

















  3. A thirdparty plugin needs to be used to package the application. In the example shown below I am using a j2me-maven-plugin provided by The plugin is configured to execute the j2me:package goal during the package phase of a Maven build. The goal creates a jar and a jad file for application, along with essential entries in MANIFEST.MF. Important configuration details are as follows:
    • Name of middlet(s) to be included in the application need to be explictly specified
    • WTK_HOME referenced in pom.xml is an environment variable that must be set up to point to a WTK installation before starting the build
    • Proguard is used to compact the application (i.e. remove unused classes from the application and “linked” dependencies. Entry point(s) of the application must be set with the keep option. If the application used introspection, classes used in that fashion would have to be specified as well.

    When mvn package is executed the build script creates files named mobic.jar and mobic.jad in the target directory. An entire working example can be downloaded from the Mobic SVN repository on sourceforge:

    Execution of tests will be described in a separate post.

































    -keep public class net.sourceforge.mobic.ui.MobicMIDlet








  1. Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language 😉
    See you!
    Your, Raiul Baztepo

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: