Java XML Programmers Reference
Chapter 11: XML Tools for Information Appliances
October 15, 2001
Sample Application: Contact Infrared Beamer
In this section, we'll show you how to install the Java KVM and Palm OS Emulator on your machine. Then we'll bring together some of the different technologies we've talked about in this chapter Java and XML on a Palm OS device. We'll create a complete lightweight Java XML application using these tools:
The application allows data entry of contact information into a custom Palm database we'll call the contact book. The term database in Palm OS lingo is rather deceiving as there is no way to create and drop tables on the database. It's better to think of a Palm OS database as permanent data residing in a section of non-volatile memory. The section is comprised of variable-length records. Each record is a variable-length array of bytes. There aren't tables, columns, or rows in a Palm OS database at all. Nevertheless, database is standard terminology.
Our application will beam contact information from a custom Palm database (called the "contact book") to the same database on another Palm OS device. Data will be packaged as an XML document on the sender's side, and received and parsed on the receiver's side. The user will then be prompted to accept the data into his contact book or not. If accepted, XML will be stored natively as a new record in the contact book database. The application also provides a mechanism to enter, search, view, and edit contact entries in the contact book database.
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:
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.
|PAGE: 1 | 2 | 3 | 4 | 5 | 6 | 7 | NEXT PAGE|