Sunday, March 27, 2011

Setting up J2ME environment

First of all it is needed to download and install WTK from Oracle. There is a distributives for Windows and Linux platforms.

After downloading the WTK I have launched the installer and got an error: No suitable Java interpreter was detected. After this message occurred there is an option to specify path to Java interpreter manually. I have provided path /usr/lib/jvm/java-6-openjdk/bin/ and completed the installation.

Since this is the first J2ME application I am developing, I need some examples and getting started materials. First of all I have tried maven archetype for J2ME applications. Well, it was good and produced working J2ME application out of the box, however it does not provide any capabilities for Eclipse integration. No emulator launch from Eclipse, no debug, no device customization etc. etc... So, maven is not an option.

Next try was MTJ (Mobile tools for Java) -- Eclipse plug-in to develop J2ME applications. This plug-in is quite powerful and allows to do many things like localization and device/profile configuration easily from UI.

For localization this plug-in generates two classes which handle the resource bundles. However, these classes do not work well with UTF-8, so Russian characters were corrupted on my HTC Diamond Touch2 running Windows Mobile 6.1. I have also tried to write Russian characters in UTF-8 format like \uXXX (which is usually well-understood by JVM), but generated parser does not treat these notation correctly. Debug also did not work for me here. Breakpoints were skipped while logs contained timeout errors. Another thing is that MJT builds JAR/JAD for some one predefined device/profile which is not always handy (if development considers running on several device types).

Polish framework

Eventually I have downloaded Polish framework for J2ME applications. After it was downloaded and installed (it, of course also requires WTK), I have imported all sample applications provided with the installation to Eclipse (simply File -> Import -> Existing projects into workspace) and got good example base. All projects go with the Ant build.xml file which has goals for build, launching emulator and debug. So, currently I have stopped on this configuration and going to use it for my project.

No comments:

Post a Comment