Steps to Code MIDets

Note: This page is not a tutorial yet. It is only a reference for myself  when coding MIDlets.

Step 1 - Coding the MIDlet
Involves using a simple text editor.

 

Step 2 - Compiling the  MIDlet

Involves using the standard Java compiler to compile the MIDlet source code files. 

Content of Compile.bat file: 

javac -g:none -d tmpclasses -bootclasspath d:\j2mewtk\lib\midpapi.zip -classpath tmpclasses;classes Directions.java

 

Step 3 - Pre-verifying the MIDlet

J2ME toolkit enters the picture. You are required to pre-verify the compiled byte-code classes using a special pre-verification tool. 

Content of Preverify.bat file: 

d:\j2mewtk\bin\preverify -classpath d:\j2mewtk\lib\midpapi.zip;tmpclasses -d classes tmpclasses

 

Step 4 - Creating the Manifest File and Packaging the MIDlet

Example:

MIDlet-1: Directions, /icons/Directions.png, Directions
MIDlet-Name: Directions
MIDlet-Description: Directions MIDlet - Mapquest.com
MIDlet-Vendor: Michael Morrison
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-1.0

Use the Java archive (JAR) tool to compress the MIDlet source code files, resources, and manifest file into a JAR file.

Content of Package.bat File:

jar cmf Manifest.mf Directions.jar -C classes . -C res .

 

Step 5 - Creating an Application Descriptor File (JAD)
Requires you to create a special application descriptor file, which is a text file containing information about your MIDlet. This is the file you specify to the java emulator when testing.

Example:

MIDlet-1: Directions, /icons/Directions.png, Directions
MIDlet-Description: Directions Example MIDlet
MIDlet-Jar-Size: 1620
MIDlet-Jar-URL: Directions.jar
MIDlet-Name: Directions
MIDlet-Vendor: Michael Morrison and Siomara Pantarotto
MIDlet-Version: 1.0

 

 

Step 6 - Testing the MIDlet

Test the MIDlet using the j2ME emulator.

Content of Emulate.bat File:

java -cp d:\j2mewtk\lib\kvem.jar;d:\j2mewtk\lib\kenv.zip;d:\j2mewtk\lib\lime.jar;Directions.jar -Dkvem.home=d:\j2mewtk com.sun.kvem.midp.Main DefaultGrayPhone -descriptor Directions.jad.

 

 

1