Running j2me application with MicroEmulator

Starting MIDlet from command line

  1. Use MainClass
    java org.microemu.app.Main (MIDlet application main class)
    or
    java org.microemu.app.Main (MIDlet jad file)
    or
    java org.microemu.app.Main (MIDlet jar file)
    • microemulator.jar must be in CLASSPATH
    java -cp microemulator.jar;YourApp.jar org.microemu.app.Main com.yourcompany.YourMidlet
    or
    java -cp microemulator.jar org.microemu.app.Main path2yourApp/YourApp.jad
    or
    java -cp microemulator.jar org.microemu.app.Main path2yourApp/YourApp.jar

    N.B. On Unix/Linux replace ; with :

  2. Use microemulator.jar
    java -jar microemulator.jar (MIDlet application main class)
    or
    java -jar microemulator.jar (MIDlet jad file)
    or
    java -jar microemulator.jar (MIDlet jar file)
    • (MIDlet application main class) parameter is optional, if used MIDlet application jar file must be in CLASSPATH,
    • (MIDlet jad file) must have .jad extension,
    • (MIDlet jar file) must have .jar extension,
    • to support Nokia UI include microemu-nokiaui.jar to the CLASSPATH,
    • to support Siemens API include microemu-siemensapi.jar to the CLASSPATH.
    java -cp microemulator.jar;microemu-nokiaui.jar;YourApp.jar org.microemu.app.Main com.yourcompany.YourMidlet
    or
    java -cp microemulator.jar;microemu-siemensapi.jar org.microemu.app.Main http://wwww.yourcompany.com/download/YourApp-sim.jad
    or
    java -cp microemulator.jar;microemu-siemensapi.jar org.microemu.app.Main http://wwww.yourcompany.com/download/YourApp-sim.jar

    MicroEmulator command line options

    • --rms [memory | file] » persistent or not RecordStoreManager manager
    • --device | -d device_class_or_xml » specify device skin.
    • --resizableDevice width height » force to use resizable device skin with specified width and height.
    • --classpath | -cp CLASSPATH » Extensions class path entries
    • --appclasspath | -appcp CLASSPATH » for MIDlet application components if any; ignored when opening .jad
    • --appclass library.class.name » for appclasspath auto detection from system classpath; ignored when opening .jad, Also see --appclassloader relaxed
    • --appclassloader strict|relaxed|delegating|system » MIDlet classloader configuration
    • -Xautotest:JAD file url » Run MIDlet in autotest mode
    • --id EmulatorID » Set emulator instance ID. Enables multiple instance of Emulator with different config file $home/.microemulator/EmulatorID/config2.xml
    • --impl JSR implementation class name » Initialize and register optional JSR implementation or Extension class.
    • --headless » Run MicroEmulator in console, NO UI headless mode
    • --logCallLocation true|false » Add System.out.print() calls origin
    • --traceClassLoading » Print loaded MIDlet classes
    • --traceSystemClassLoading » Print system classes loaded by MIDlet
    • --enhanceCatchBlock » Change MIDlet internal exception handling to print silently ingored Throwable
    • --quit » exit emulator on MIDlet destroy
    • --quiet » Disable stdout logs
    • (MIDlet class name | jad file location | jar file location)

    Other examples

    java -cp microemulator.jar;microemu-device-large.jar org.microemu.app.Main --device org/microemu/device/large/device.xml http://wintermute.de/wap/5ud0ku.jad

    MicroEmulator with JSR

    java -cp microemulator.jar;bluecove-1.2.3.jar org.microemu.app.Main btbrowserv20.jad

Starting MicroEmulator without UI

It is possible to run MicroEmulator in headless mode, all command line parameters applies like in standard UI mode. It is necessary to provide different main class: org.microemu.app.Headless

java -cp microemulator.jar;YourApp.jar org.microemu.app.Headless com.yourcompany.YourMidlet
or
java -cp microemulator.jar org.microemu.app.Headless path2yourApp/YourApp.jad
or
java -cp microemulator.jar org.microemu.app.Headless path2yourApp/YourApp.jar

Headless MicroEmulator additional command line options

  • --logCallLocation » Add System.out.print() calls origin

Building and debugging a java project using MicroEmulator and Eclipse

All you need to do is to configure Run Command to start Emulator Directly from the IDE.

Click on your project, go to Run > Run.

Double click "Java Application" to create a run type. Name this new run command.

For Main class, put in> org.microemu.app.Main and select "Include libraries when searching for main class" .

Java Main class

Click the "Argument" tab and this under Program arguments enter you MIDlet class name.

Java Argument class

If your MIDlet project includes other projects or libraries that are compiled differently and included in you final application. e.g. XML or Log libraries. Then you need to add aditional configuration option. MicroEmulator will use the same MIDlet classloader for this clases. If not specified this classes would be loaded by the same classloader as MicroEmulator e.g. SystemClassLoader.

--appclasspath /home/bob/work/framework0.1.jar;/home/bob/work/core/target/classes org.app.MainMIDlet

More convenient option is to let MicroEmulator detect the location of the classes in project classpath. Only one class name from each library or project needs to be specified.

--appclass org.framework.OneClass --appclass org.core.AnotherClass org.app.MainMIDlet

Finally, go to the class path, add your project (done already by default), and add microemulator.jar (under User Entries)

Integration of MicroEmulator into Eclipse EclipseME project

The described above approach is working when your project is EclipseME project. In this case you need to specify Runtime JRE.

Select Execution Environment: J2SE-1.4, J2SE-1.5 or JavaSE-1.6

Java Execution Environment

As of EclipseME version 1.7.0 it has its own support for MicroEmulator. Import MicroEmulator installation directory using Window -> Preferences -> J2ME -> Device Management Then just select MicroEmulator as J2ME Device using EclipseME menus and properties.