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).

Tuesday, 23 October 2007

KJAR has a virus

A few months ago i started using KJAR to compress jar files. It worked well, eliminating 10% space of a 110KB jar file. But it turned out to have a trojan horse virus in it which my anti-virus software eventually dealt with. So beware!

If anyone has an uninfected version i would like to hear from you.

Here is the site (which is otherwise excellent) where i got the infected KJar http://supremej2me.bambalam.se

Java Micro Edition on Windows Mobile

For one of our customers we were asked to make a mobile application on the hardware of their choice. In this case a hardened PDA with windows mobile on it. The devices are great, you can drive your car over them or drop them in the bath and they still work!
Anyway, examination of the devices revealed that they had no Java support. So did we decide to take the MS Visual Studio route? Of course not, we eat, drink and breath Java, so we're not going to let that happen are we....

A quick search of the net revealed some promising candidates for virtual machines that can be installed on windows mobile. Some time later we were narrowing it down to one (1) alternative: IBM's J9 Websphere Everyplace Micro Edition. That's all there is in this space at the moment. Nothing else. Zilch. All the others have disappeared, are limited time trials or been bought and are now kept under lock and key. Luckily you can download an unlimited trial version from the IBM website. Download it quickly because i have the feeling it won't be there for long. Register and search for "IBM J9 WEME". You should get a plethora of download options. More on that later.

Although i'm no microsoft expert there seem to be a definite advantage for software vendors to using java over the .net compact stuff:

  • The .net compact framework (or whatever it is that microsoft calls its application development stuff nowadays) seems to be slightly different on Windows CE, 2003, 2005 and 2006. We tried a demo application that was written for 2005 and it didn't work on 2003. So if your client decides they will be using windows mobile 2003 you have to change your software. Presumably this applies to windows mobile 2006 as well. Of course there are different java versions and compatibility problem in j2me apps, but you can fix that by upgrading to a new java VM which is nowhere near as drastic as upgrading the whole operating system.

We eventually got both the emulator and device runtime working for both MIDP 2.0 and Personal Profile and even got SWT running. Our application does network connections, uses the touchscreen, has a low level user interface and uses the Midlet lifecycle methods actively. All of these things were non-trivial in the IBM virtual machine.

I'm out of time right now. In the coming weeks i'll be writing on how to install it, how to run it (even harder) and what things don't work or work in a completely unexpected way.

Why this blog?

The last two years i've been looking for information about mobile web and mobile java.... and been quite frustrated about what i found, or rather didn't find.
My first encounter with all things mobile was in 2000 for a Vodafone / Vivendi startup. In those days it was really really hard to find any reliable information about mobile technology. So the company i was working for burned humungus amounts of cash to find things out by trial and error. Recently i started a company geared towards mobile web and applications and i was expecting the mobile software industry to have matured and opened up in the way enterprise software has in the last 5 years. But to my amazement this is not the case. It is a little easier to find your way around the mobile circus than it was in 2000, but i think it is still much too hard. While giving a course on mobile technology last month i realized that a lot of the stuff i was telling the students is excruciatingly hard to find on the net. Sure there are some forums you can look at, but if you work in mobile software development chances are you will be using several technologies, each equally obscure and undocumented. Wouldn't it be neat if the information you needed was bundled somewhere.


So here is my attempt to bundle useful information for software developers and users of mobile software. I will be adding stuff slowly but on a regular basis. I'm hoping it will save a lot of people a lot of time and frustration.

Happy reading,
Robin