phoneME for Android
The Android port of phoneME Feature and Advanced is merely a proof-of-concept that running J2ME applications and midlets on Android is possible. Check out the builds in the Downloads section (look for the apk Android packages).
Each build includes the phoneME VM and a Android frontend wrapper with JNI bindings to the VM. Have a look at some of the screenshots. Here is a discussion of the main issues that had to be resolved.
More information about the phoneME project and these two types of virtual machines can be found at https://phoneme.dev.java.net.
The phoneME software is copyright (c) 1990-2011 by Sun Microsystems, Inc. (now Oracle) and licensed under the GNU General Public License (GPL) version 2. The builds for Android based operating systems on this site are based on the phoneME software and includes code copyright (c) 2007-2011 by Davy Preuveneers released under the same GPLv2 license. More details about the changes made to the original code are available on this site.
In order to build phoneME for Android, you need to first compile Android itself to get all the required native libraries. You can get the sources and the toolchain from the Android source code repository. Then the phoneME sources need some tweaking as well. I can also recommend using the agcc wrapper script to simplify the build process. The builds in the Downloads section were made after compiling with the following changes:
Note that not all the change sets in the diff are mandatory. There is still some code in there that is used for testing purposes. Also, there is some tweaking with the MIDP graphics to get a nice look and feel on a 800x480 display and the dragging feature was disabled for smoother interaction. There are several other quick hacks in there that probably need a more appropriate fix.
HowTo Run CLDC-based Applications
For CLDC-based applications, package the classfiles in a preverified JAR file. Copy the JAR file onto an SD card or use the Android adb SDK utility to push the JAR file onto your device. You need to create a textfile with .args file extension in which you specify all the VM parameters, e.g. '-cp /path/to/app.jar Main arg1 arg2 arg3'. Make sure you always specify the full path of the java archive starting from the root of the filesystem. Contrary to CDC, with CLDC you cannot execute a jar file directly as in '-jar /path/to/app.jar'. You need to specify the classpath and main class. Save the file e.g. as app.args
Run the CLDC Android application as follows: select this ARGS file on your SD card after clicking on the Open button, and tap the Run button.
HowTo Run CDC-based Applications
If you want to run a simple J2ME Foundation Profile application, package it as a JAR file with a manifest file having a Main-Class entry. Copy the JAR file onto an SD card or use the Android adb SDK utility to push the JAR file onto your device. Run the Foundation Profile-MIDP Android application, select the JAR file on your SD card by clicking on the Open button, and push the Run button. The application will be executed as in 'cvm -jar /path/to/app.jar'.
HowTo Run MIDlets
If you want to run a midlet copied onto the filesystem, make sure you have both the JAR and JAD file in the same directory (e.g. /sdcard/midlets), and that the MIDlet-Jar-Url entry in the JAD file is a local file reference to the JAR file rather than an external http url.
Follow the same steps as before but select the JAD file instead, and push the Run button.
JAD files are also associated with the Foundation Profile-MIDP Android application. Therefore, you can also use your browser to select an online JAD file to download and run the midlet. If you click on a JAD download link, a popup menu will appear and you need to choose the Foundation Profile-MIDP Android application:
The midlet (JAR and JAD file) will be cached onto the filesystem in the Android application's data space. If the JAR file of the midlet is quite big, the Android application may be a little unresponsive while downloading the file.
Also be aware of the following:
- I have only done limited testing. I don't have a real Android phone (only the Android emulator, and a port of Android 2.2 for a Windows Mobile device). Use at your own risk.
- The phoneME VM is built as a native library. If it crashes or exits, it will also terminate the Android wrapper application.
- Graphics and font sizes are optimized for a 800x480 display, and may be too big for smaller display resolutions.
- Screen rotation for midlets, native JNI libraries, and probably several other features do not work.
- The MIDP part does not include any JSR support for midlets to handle audio, video, sms, 3d, bluetooth, etc.