Either performed automatically by an IDE or done by hand or automated via ANT. The end result is a set of class files. In this example there should be two files: HelloWorld.class, and HelloWorldCanvas.class.
JARing
The project classes, the manifest and resource files are bundled into one file: HelloWorld.jar.
Preverification
Unlike J2SE classes J2ME classes must have their contents preverified prior to execution on the device. This is compensation for the limited processing power of mobile devices. This stage includes checks for illegal bytecode or constructs not supported by J2ME.
The preverify tool comes with most emulators and for Mac users the MPowerPlayeroffers an OS X compatible binary.
JAD Updating
The JAD file has its contents updated to reflect the properties of the JAR file.
To download JammedUp click here.
(Learn more about JammedUp…)
(Learn more about JammedUp…)
Automating the build process with ANT
ANT can be used to perform all of the build steps in sequence saving you much time and effort. The source code download also includes a sample ANT build script.
build.xml
<project name="helloworld" default="dist" basedir="." >
<property name="app.name" value="helloworld" />
<property name="app.path" value="/${app.name}" />
<property name="build.home" value="${basedir}/build" />
<property name="lib.home" value="${basedir}/lib" />
<property name="dist.home" value="${basedir}/dist" />
<property name="src.home" value="${basedir}/src" />
<property name="compile.debug" value="true" />
<property name="compile.deprecation" value="false" />
<property name="compile.optimize" value="true" />
<target name="all" depends="dist" description="Clean build and dist directories, then compile" />
<target name="clean" description="Delete old build directory">
<delete dir="${build.home}" />
</target>
<target name="compile" description="Compile Java sources">
<javacsrcdir="${src.home}" destdir="${build.home}" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}">
<classpath>
<filesetdir="${lib.home}" includes="*.jar,*.zip" />
</classpath>
<include name="**/*.java"/>
</javac>
</target>
<target name="bundle" depends="compile" description="Takes the built objects and makes a JAR file.">
<mkdirdir="${build.home}/META-INF"/>
<copy todir="${build.home}/META-INF">
<filesetdir="META-INF" includes="**/*.MF" />
</copy>
<jar jarfile="${dist.home}/HelloWorld.jar" basedir="${build.home}" includes="**/*.class" />
</target>
<target name="preverify" depends="bundle" description="Preverifies the JAR file.">
<exec dir="${dist.home}" executable="<path-to-project>/dist/preverify">
<arg line="-d ${dist.home} -classpath ${lib.home}/cldcapi11.jar:${lib.home}/midpapi20.jar ${dist.home}/HelloWorld.jar"/>
</exec>
</target>
<target
name="dist"
depends="preverify"
description="Create binary distribution">
<exec dir="${dist.home}" executable="java">
<arg line="-cp %CLASSPATH%;.;.. -jar JammedUp.jar HelloWorld.jad -b -d -s"/>
</exec>
</target>
</project>
