Alex Sherman's homepage




FairTorrent project

Coding Seminar

Java on Palm OS


Danny Lewin


Measuring wireless bandwidth on Palm Treo AND getting Java to work on Palm OS

We ran a project in the summer of (2006) with several high school students that involved measuring wireless bandwidth available in the New York city area via several service providers. To accomplish this we wanted to put measurement software on Palm Treo devices of Sprint, Verizon, Cingular and others.  While this goal appeared easy we found no software available that could simply be placed on those devices. We found a few  web-based measurement tools did exist but they typically carried so much overhead that made the experiments quite unreliable. Finally, I wrote a small Java program that would download web pages and measure the available bandwidth. Surprisingly, even getting Java to work on these devices was not as trivial as good documentation was not readily available. Here I document steps that I took to get Java working on the Palm Treos 650 and 700 running Palm OS as well as getting to write, build and test Java applications for Palm on my Windows NT box. 

1.  This document on the Sun's website was a good starting point to get to write and build Java applications for J2ME on a Windows box.  Some of the steps below are taken from this document.

2.  Install the standard Java SDK on your Windows box (this is before you get to  J2ME support for Java Mobile) . Java SE 1.5 or later (which I believe is now called 5.0) is available for download from   It's important to begin with a Java SDK, as any J2ME package (for Java Mobile) will use the SDK environment and augment it with additional classes.

3.  Make sure that the Path environment variable on your Windows system includes the path to the "bin" subdirectory of your SDK installation directory so that the programs like javac (Java Compiler) and java could be called without specifying the full path. This is important because J2ME toolkits will need to call these Java commands. For Windows NT, to modify the Path go to Control Panel -> System -> Advanced , and click on "Environment Variables". In my case I had to add: "C:\Program Files\ Java\JDK-1.5\bin"  to the Path variable. (I believe for Windows 98 you need to modify autoexec.bat). You can test whether you set this Path correctly by running "java -version" from a command prompt. 

4.  Download and install the Sun Java Wireless Toolkit. Once you've installed and added this kit to the list of program files you'll find a few useful subprograms inside. First "Ktoolbar" is a very useful tool to manage and build your java projects for J2ME ( a few samples are included - just copy and modify).  Second it contains an emulator program ("Run MIDP...") of a wireless device that you can use to run your application. Most importantly it contains the J2ME classes for wireless device programming. Note, when a creating a new project with "Ktoolbar" you want to set it to build for "MIDP 2.0"  which is a JVM for newer Palm OS versions. 

5.  Although this is optional I also downloaded Jedit - a useful tool for editing Java code.

6.  Now to port the code to the actual palm device you need a JVM that will run on Palm OS. This part I obtained from To obtain this JVM I registered for the "developer network" at Palm OS. It may take a day to actually obtain access once you register.  Then I was able to download the "WME Developer toolkit for Palm OS" from This toolkit contains similar tools to the Sun Java Wireless Toolkit, but more importantly it also contains the JVM (.prc files for Palm OS). The documentation that comes with this toolkit will detail which .prc program files to install on your Palm.  One important note here is that when searching on the web at first I found references to MIDP 1.0, which is a much out-dated version of a JVM for Palm and will most likely crash your device.

7. Now to start and build your own program use the "Ktoolbar" from the Sun toolkit (step 4).  You can start by copying a directory from a sample project that comes with that toolkit. You can then run it in the emulator using the same toolkit. This will save you a lot of time in debugging instead of HotSyncing to your Palm each time you modify your code.  To convert the .jar file built in Ktoolbar to a Palm program (.prc) use the jar2prc tool that comes with both toolkits (downloaded in steps 6 and 4).  In that program input the path to your project's .jar file (built by Ktoolbar) and it will output the .prc. The GUI for the program also askes for a .jad (a description file). But you can get away with just a .jar.  The resulting .prc should be installed on the Palm via HotSync.

Now a couple of comments about the actual bandwidth measurements. Here is the Java code that I used. 
You need to replace the settings of url0, url1 and url2 with some actual downloadable web files. url0 should be a small sample file. I use it only to get rid of the initial overhead. For instance if the Internet mode is not even on - attempting to download this file will prompt you to turn it on. url1 and url2 are larger files - enough to test the bandwidth. I used 1 and 2MBytes for these files. 
Notice that this test buffers 10KB of the downloaded file at a time and throws it away. This is meant to circumvent memory or "disk" constraints and measure the pure maximum allowable bandwidth. We found that the browser-based tests were more limiting on the Palms because of memory/processing limitations when loading web pages.
Note however, that the buffer length cannot be too large. For instance if it is larger than certain memory limitations of the device - the Java applet will simply stall. I found that using 100KB buffer would crash Palm Treo 650 and 700. 
Using this test you will probably find that the available bandwidth varies tremendously with the service provider, time and location. But you'll see much higher numbers coming out of this test than a browser-based test as this is a a pure bandwidth test.