ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Java Programming for Palm OS
Pages: 1, 2

The IBM Solution

IBM has its own virtual machine, called J9, which in many ways is superior to the KVM. J9 is supported by the Visual Age Micro Edition, an IDE from Object Technology International, a wholly-owned subsidiary of IBM. VAME is a full-featured development tool that gives you full access to the Palm OS API. This comes at some cost, however. While VAME is a Java tool, what it provides is a wrapping of all the native C methods of the Palm API in Java. As such, the method calls in VAME are exactly the same as you would find in C. Therefore, you need to have some understanding of the structure of the Palm API and the arguments to each method. While it is never a bad thing to understand the OS that your application will run under, the need to be familiar with the method signatures of the C API for the Palm is a problem if you are a Java-only developer. This is a drawback that the engineers at OTI seem aware of and are intent on improving.

The following is a simple example written under VAME:

import com.ibm.oti.palmos.*;
import com.ibm.oti.palmos.util.OSX;

public class HelloJ9 implements OSConsts {

public static void main(String[] args) {

   CharPtr title = new CharPtr("IBM Vame Demo");
   EventType event = new EventType();

   try {
      FormType form = OS.FrmNewForm(0, title, 0, 0, 160, 160, 0, 0, 0, 0);

      OSX.WinDrawChars("Hello J9!", 5, 30);

      while(true) {
         OS.EvtGetEvent( event, -1 );
         if (OS.SysHandleEvent( event )==0) {
            if (event.getEType() == appStopEvent) {

      } finally {

As you can see, it looks a bit different than the previous examples. If you can get past this hurdle, your application performance will be far superior to a KVM-based app. The other distinct advantage of VAME is that since it accesses all of the native API calls, any Palm Database you create can be synchronized with a conduit. The distribution of VAME comes with some nice examples which can get you through some of the difficulties. You can obtain a copy of VAME from www.embedded.oti.com.


Waba is yet another VM that's the work of several individuals. In style, Waba is somewhat between Kjava and Kawt. While it includes many more GUI components than kjava, it uses coordinate position to place components on the screen, rather than kawt's layout manager approach

The advantage of Waba is speed. It is indeed faster than the KVM. If you think your application may target more than just the Palm OS, Waba also runs under Windows CE. There are extensions to Waba as well, called Superwaba, which provide even more functionality.

Here is the same small app written with Waba. It uses an additional class (not shown) to set the title:

import waba.ui.*;
import waba.fx.*;

public class HelloWaba extends MainWindow

Button closeButton;

public HelloWaba()
   Title title = new Title("HelloWaba");
   title.setRect(0, 0, this.width, 15);

   closeButton = new Button("Close");
   closeButton.setRect(0, this.height - 15, 44, 15);

public void onEvent(Event event)
   if (event.type == ControlEvent.PRESSED)
      if (event.target == closeButton)

Waba has some nice perks, including; the ability to copy and paste using the clipboard, and access to the System keyboard for easier text entry. In addition there is a class which encapsulates some of the VM details, allowing you to determine which platform that the VM is running under and which ROM version.

Waba is available from www.wabasoft.com. SuperWaba is available from www.superwaba.org.


The choice of Java solutions for writing Palm OS applications depends on several factors: whether you are targeting the Palm OS only; whether speed or ease of development is more important. And this is far from the last word on Palm programming with Java. The landscape is bound to change even more in the future.

Matthew E. Ferris is President, Chicagoland Java User Group, a Sun Certified Java Programmer, and a contributing Author for Professional Java Server Programming, Wrox Press.

Return to ONJava.com.