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

advertisement

AddThis Social Bookmark Button

Palm Programming with Waba
Pages: 1, 2, 3

Compiling the application

To compile a Waba class file into a prc file, which is executable under the Palm OS, you need to call two programs that come with Waba, warp and exegen. Both of these are found in the bin directory under the <waba_install> directory. The warp utility creates a WRP file and a PDB file. The WRP file is of no use to a Palm device, but recall that Waba also runs on Windows CE, which is what the WRP file is for. Warp will generate a default creatorID for the PDB file, but this can be overridden with the /c option, allowing you to specify a creator ID. The creator ID is a four-byte identifier that is used by the Palm OS to tie together applications and data. If you distribute an application commercially, it is a good idea to have a unique creatorID, so that your application and data do not inadvertently clash with some other application on the device. You can register a creatorID on the PalmOS web site.



Thus the following command would create a pdb file from our ContactManager class.

warp c /c cnTc ContactManager *.class

The first c tells warp to create the PDB file. The other flag is l, which will list the contents of the PDB file. The /c will set cnTc to be the creatorID associated with this PDB file. At least one byte of a creator ID must be uppercase. The next parameter is what the PDB file should be called -- in this case, ContactManager. Finally, the necessary class files should also be included in the PDB file. Our ContactManager application has only one class, so it is not important that we have specified the wildcard. However if the app had many classes, this syntax would add them all to the PDB file.

The Exegen utility is the other program that must be run against your application in order to ready it for Palm OS execution. This creates a PRC file, which will provide the Palm OS with its entry point into your application. Exegen's command line parameters look like

Exegen [options] exefile main-window-class warpfile [warpfile2...]

Thus for our ContactManager application, we would run

Exegen ContactManager ContactManager ContactManager

This would specify that the name of the PRC file should be called ContactManager, our class that extends the waba.ui.MainWindow class is called ContactManager, and the warp file, which contains our class file(s) is called ContactManager. As you see, you need to run the warp utility prior to running Exegen.

After this completes, you will then have a PDB and a PRC file, which you can alternately download to the Palm device itself, or to the Palm OS Emulator (POSE). POSE is a recommended utility for aiding the compile-edit-run cycle. It is far less trouble to run your app in the emulator than to do so in the device.

Of course before you can run this on either, you need to download the Waba VM itself. Download both the waba.prc and waba.pdb files

The other options that can be specified with Exegen are listed below:

/h Assign height of application's main window
/i Assign PalmOS PRC icon (e.g. /i sample.bmp)
/l Assign size of class heap (e.g. /l 10000)
/m Assign size of object heap (e.g. /m 20000)
/p Full path to directory containing warp file under WindowsCE
/s Assign size of stack (e.g. /s 2000)
/t Assign size of native stack (e.g. /t 50)
/w Assign width of application's main window

As you can see, there are several flags allowing you to optimize memory usage in your application. It has been my experience that some of these can make a profound difference. For example, without enough class heap size, the Keyboard will not display, but rather throws an exception.

Altering our earlier exegen command, then, we might run it as

exegen /q /i icon.bmp /t 1000 /s 2000 /m 65500 /l 40000 ContactManager

This allows us to set some memory allocations for the VM to make our class run more efficiently. It would be wise to experiment with different values here to find what is optimal for your application. This will depend on how many classes you have, and how many objects you initiate at one time. In device programming such as this, it is always a good idea to be stingy with the number of objects you create.

Pages: 1, 2, 3

Next Pagearrow