The topic of Java specifications and JVMs designed for embedded and portable devices is a long and involved story, which is clearly beyond the scope of this chapter. I would like to touch on a few of the highlights, however, in order to give you an idea of how the implementations on which this chapter is based fit into the overall scheme of Java Virtual Machines.
Between Sun's official and ever-evolving specifications and the growing number of proprietary third-party solutions, clearly defining the myriad specifications, profiles, and configurations out there is not a simple task. From a high level, however, Java is divided into three editions:
Naturally, this chapter is primarily concerned with J2ME; however, due to the immense diversity of embedded and portable devices (cell phones, set-top boxes, PDAs, pagers, and so on), it is necessary that J2ME be divided into various "configurations." Sun defines two configurations within J2ME: the Connected Device Configuration (CDC) and the Connected Limited Device Configuration (CLDC). The CDC makes use of the same JVMs typically run on desktop devices, while the CLDC uses the KVM (Kilobyte Virtual Machine a VM whose size is measured in the tens of kilobytes rather than megabytes), a virtual machine designed for devices with more limited resources. Each configuration is then further subdivided into profiles that attempt to group devices based on common or similar functionality and attributes and define platform-appropriate APIs. As if classifying and categorizing devices were not difficult enough, the matter is further complicated by devices' rapid evolution and the increasing number of third-party solutions meant for faster CPUs, larger memory footprints, and longer battery lives.
That said, the question remains: How do you run Java on a Pocket PC device? For the purposes of demonstration, my device of choice is the Compaq iPAQ 3630, and the best Java solution I've found (and the implementation on which the code in this chapter is based) is PersonalJava, which, in J2ME-speak, falls under the Personal profile of the Connected Device Configuration. Sun's 1.1 implementation (3.0 in terms of application environment) is essentially a scaled-down version of Java 1.1.8, which means not all 1.1.8 packages are fully implemented. It is still in beta, but seems to work well enough. And, most importantly, it is completely free. The StrongARM implementation can be downloaded from http://developer.java.sun.com after a quick and free registration process.
There are several other PersonalJava implementations available for the more adventurous among you. Most notably, there is the Jeode platform built by Insignia Solutions (www.insignia.com) and the Kada VM from Kada Systems (www.kadasystems.com/kada_vm.html). At the time of this writing, Kada's Pocket PC JVM was still in beta or as they like to say, "debug"; however, you will want to go have a look for yourself because embedded Java technology is moving at an extremely rapid pace. Without much effort at all, I uncovered over a dozen more PersonalJava implementations, so there are plenty to choose from and experiment with. Again, I can only personally speak for Sun's (free!) implementation.
I'm not going to cover installation of PersonalJava here on the off chance that Sun releases a new version or otherwise alters the process. I will mention, however, that it is as straightforward as unzipping, copying, and tapping. Once installed, you can run PersonalJava either from the command line, or simply by tapping on class files copied over from your PC.