Setting Up the Environment
In this section, we'll walk through the setup and installation of the Java KVM and POSE.
CLDC and Java KVM
First, download the J2ME CLDC v1.0.2 (see CLDC), and the kjava overlay from:
http://www.sun.com/software/communitysource/j2me/cldc/download.html
Unzip j2me_cldc-1_0_2-fcs-winunix.zip first. Then unzip j2me_cldc-1_0_2-fcs-kjava_overlay.zip using the same directory base in which you unzipped the first file. Overwrite any existing files.
The first archive contains the CLDC reference implementation for Win32, Solaris, and Linux. It includes source code, runtimes, tools, and documentation for porting the CLDC to other platforms. This archive is designed to be used with a profile (see Profiles).
Since there is no PDA Profile implementation yet (see PDA Profile), we'll use the CLDC-compatible port for the Palm contained in the overlay archive. This is the second archive you downloaded, the kjava overlay. The overlay installs Palm-specific tools, samples, the all-important package com.sun.kjava (see Package com.sun.kjava), and KVM.prc the Java KVM packaged as a Palm application.
The overlay is not intended to be used alone; it must be installed after and on top of the first archive, overwriting any existing files.
Palm OS Emulator (POSE)
We'll use the POSE as our testing platform as we write our code. The POSE runs on Win32, Solaris, or Linux (although you could compile it for another platform as the source code is available). Remember our application will beam addresses from one Palm OS device to another. Obviously, the POSE doesn't have an infrared port since it's just software. So to test the application fully you must have two Palm OS devices (Handspring Visors, Sony Cliés, or IBM Workpads are fine).
Step 1 Install the Emulator
First, download the emulator from http://www.palmos.com/dev/tech/tools/emulator/. It is available for Windows (as a ZIP file), Macintosh (as a SIT file), and for UNIX (source code in a TAR that you must compile). Extract the file.
Step 2 Obtain a ROM Image
Before the emulator will operate, it needs a binary image of the environment to be emulated. The base installation doesn't come with any ROM images. If you own a Palm OS device, you can download an image of that device's ROM using the emulator. Simply run emulator.exe, which was installed in Step 1, and select "Download a ROM image from a Palm OS device." Detailed instructions are then given; it's really quite a simple process.
If you don't own a Palm OS device, you can download a ROM image from the Palm web site (http://www.palmos.com/dev/tech/tools/emulator/#roms). You'll need to join the Palm Alliance Program, which simply requires you to fill out an online form.
Step 3 Run the Emulator for the First Time
Now you should run emulator.exe, which was installed in Step 1. Click the new button, Start a new emulator session. Under ROM file, select Other and navigate to the .ROM file you obtained in Step 2. The device field should automatically populate, but if it doesn't, select the correct Palm device type. Leave skin as generic. Finally, select the RAM size that corresponds to the actual RAM of the device you are emulating (for example, if emulating a Palm Vx, you should set this value to 8192KB, click OK. The emulator will then start.
Step 4 Install the Java KVM On the Emulator
Now we must load the virtual machine onto the emulator. Right-click anywhere on the emulator. From the pop-up menu, select Install Application/Database and Other. Navigate to j2me_cldc/bin/kjava/palm and select KVM.prc. The virtual machine will be installed. Now do the same for j2me_cldc/bin/kjava/palm/KVMutil.prc. KVMutil is a debugging utility that allows you to set the maximum heap size and screen output (System.out) options.