SDK API

MicroEmulator SDK API modules.

There are no CLDC or MIDP implemenations in this modules so you should not include the jars into runtime enviroment. They are indended strictly as refference and should be used only during MIDlet projects compilation and preverification the same way you are using WTK\lib\cldcapi11.jar and WTK\lib\midpapi20.jar from SUN WTK.

API documentation JavaDoc

Compiling MIDlet

Using command line javac on unix

    javac -source 1.3 target=1.1 -bootclasspath $MICROEMU_HOME/lib/midpapi20.jar:$MICROEMU_HOME/lib/cldcapi11.jar src/TestMIDlet.java

Using command line javac on windows

    set MICROEMU_HOME=C:\microemulator-2.0.2
    javac -source 1.3 target=1.1 -bootclasspath %MICROEMU_HOME%\lib\midpapi20.jar;%MICROEMU_HOME%\lib\cldcapi11.jar src\TestMIDlet.java

Using ant

    <path id="bootclasspath">
        <pathelement path="${MICROEMU_HOME}/lib/midpapi20.jar"/>
        <pathelement path="${MICROEMU_HOME}/lib/cldcapi11.jar"/>
    </path>
    <javac destdir="build/classes" srcdir="src" target="1.1" source="1.3">
        <bootclasspath refid="bootclasspath"/>
    </javac>

Using maven

<project>
    ...
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.3</source>
                    <target>1.1</target>
                    <fork>true</fork>
                    <compilerArguments>
                        <bootclasspath>${env.MICROEMU_HOME}/lib/cldcapi11.jar${path.separator}${env.MICROEMU_HOME}/lib/midpapi20.jar</bootclasspath>
                    </compilerArguments>
                </configuration>
            </plugin>
        ....
        </plugins>
    </build>

Use API modules directly from local maven repository.

N.B. This will not download API modules to your local maven repository. You need to have some sub project that have this modules in dependencies.

    ...
    <properties>
        <me2Version>2.0.2</me2Version>
    </properties>
    ...
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.3</source>
                    <target>1.1</target>
                    <fork>true</fork>
                    <compilerArguments>
                        <bootclasspath>${settings.localRepository}/org/microemu/cldcapi11/${me2Version}/cldcapi11-${me2Version}.jar${path.separator}${settings.localRepository}/org/microemu/midpapi20/${me2Version}/midpapi20-${me2Version}.jar</bootclasspath>
                    </compilerArguments>
                </configuration>
            </plugin>
        ....
        </plugins>
    </build>

For more information on building J2ME application using maven2 see j2me-maven-plugin

MIDlet code preverification using ProGuard

ProGuard version 4.0 introduced preverification. The -microedition option makes sure the class files are preverified for Java Micro Edition, producing compact StackMap attributes. It is no longer necessary to run an external preverifier.

    java -jar proguard.jar -injars in.jar -outjars out.jar \
            -libraryjars $MICROEMU_HOME/lib/midpapi20.jar \
            -libraryjars $MICROEMU_HOME/lib/cldcapi11.jar \
            -microedition