Monday, 29 October 2007

Which Java Micro Edition Profile for windows mobile?

Which profile/ configuration
If you've just started with java micro edition you will most likely be confused by all the configurations and profiles that are available. How do you choose which profile / configuration to use? Which configurations are widely available and which can you use on your shiny new windows mobile device that you are hoping to deploy a java app on?

Step 1. Choose a profile / configuration.
If this is your first java micro edition project, choose the CDC1.1 configuration with Personal profile 1.1. This profile will allow you to use regular java programming skills (similar to desktop application programming). For example you can use SWT for the user interface.
If you are looking to deploy your application on non-windows-mobile devices then go with the CLDC1.0 configuration and MIDP2.0 profile. At the time of writing CLDC1.0 / MIDP2.0 is the most widely available configuration an profile and is pre-installed on over 95% of telephone models.

Step 2. Check your device has suitable java support
Before you start any development at all, get a demo application from somewhere and try deploying it to your target device. Documentation for many devices is often so hard to find that you only really know you can use the configuration/profile you want if you have seen it running on a real device. The Sun Wireless CLDC/MIDP2.x Toolkit comes with a set of demo applications which you can use to test for MIDP2.x compatibility.
Most mobile phones have support for java micro edition CLDC1.0/MIDP2.0 or higher. Many windows mobile devices have no java support at all. Fortunately you can install IBM's J9 WEME runtime on windows mobile devices.

Step 3. Install a runtime if necessary.
If not pre-installed, the only real option (i've raved about this earlier) for java on windows mobile is IBM's J9 WEME runtime. J9 comes in several flavours for windows mobile. The main distinction is the CDC/Personal profile flavour on the one hand and the CLDC/MIDP flavour on the other. If you chose CDC/Personal profile, you need to download two runtimes; one for the device (wm50-arm) and one for test and debugging on your desktop (win-x86).
I find many people get confused what to download and what its for. So here's an example:
  • Runtime for windows mobile 5 devices with ARM processor (HP, HTC, Qtec, MDA etc) is in: ibm-weme-wm50-arm-ppro11_6.1.1.20061110-161633.exe
  • Runtime for windows xp desktop is in: ibm-weme-win-x86-ppro11_6.1.1.20061110-161633.exe

Blink and you will miss the difference. They both have (different) installation documents with the same name 'install.pdf'. It boils down to installing both on your desktop, unzipping one of the installed zip files (different one for each runtime) and for the device runtime copying a few directories to the device. I'll be writing more on this later this week

Step 3. Forget the optional packages (for now)
A really really annoying part of development for java micro edition is the fact that a lot of sexy stuff is in optional packages. Optional in reality means one of the following:
  • you can't depend on it being on a device
  • two devices can implement it with non-trivial differences
  • the really sexy stuff is generally only implemented on 3 phones, which are kept in a dark loft in finland and guarded by dragons.

So for now forget the location based api, the multimedia stuff, bluetooth, web services and most other mouthwatering things. Come back to them when you are a seasoned dragon-slaying java micro edition veteran.

That's it for now.
When i have time i'll be writing about how to install and run IBM's J9 on a desktop and on a real device. This defeats a lot of people because the documentation doesn't provide any useful examples. Which is a pity because it is otherwise an excellent product. When i get round to it i'll also post how to deploy an application and run it (this may sound stupid, but it took me a whole day to clear this hurdle - and judging from the forums i'm not the only one).


animus said...

Thank you for this article!!!
I spent hours on web and google and haven't found yet such an interesting article!
It is clear, and very usefull!
(excuse my poor english)

Michi said...

Unfortunately I am not yet a dragon slaying j2me developer, but at least I've made it to level 2...
I got a question though: I am interested what I would have to do to implement a VM on a device with for example the location api enabled? So far I found out, I need to use the cdc reference sources and adjust them to the device I am working on.. but how do I implement the jsr179 for example? Is it done in java? Possibly not.. I guess I've to get a dragon-slaying c coder and integrate it into the cdc c sources?