Monday, February 18, 2008

Running Existing MIDlets on the BlackBerry

To run a standard MIDlet on a Java-enabled BlackBerry device, you first need to convert the .jad and .jar files to the .cod format, using the rapc command-line tool that comes with RIM's JDE. You'll find rapc in the bin directory of your JDE installation. This command converts a MIDlet named LoginMIDlet:

rapc import="c:\BlackBerryJDE3.6\lib\net_rim_api.jar" codename=LoginMIDlet -midlet jad=LoginMIDlet.jad LoginMIDlet.jar

You can load the resulting LoginMIDlet.cod file into your BlackBerry device from your desktop computer over a USB cable. Use the javaloader command, which can also be found in the bin directory of your JDE installation. I used this command to load LoginMIDlet.cod into my BlackBerry 7510:

javaloader -usb load LoginMIDlet.cod

Once the application is loaded into the BlackBerry, you can run it just as if it were a native application.

You can use javaloader to delete applications from the BlackBerry as well as to load them. This command will remove LoginMIDlet.cod from the BlackBerry:

javaloader -usb erase -f LoginMIDlet.cod

No comments: