|
The Sharp Zaurus (SL-5000) is a geek's dream device. A color, touch-sensitive screen, a tiny QWERTY keyboard, and the Linux operating system are crammed into a palm-sized package. A CF card slot allows for an 802.11 or Bluetooth wireless networking card. Best of all, the Zaurus can run Java applications. The Zaurus was on sale at the 2002 JavaOne Conference for a steep discount. If you've picked one up, you might be wondering what you can do with the Java platform on the Zaurus. This article describes how to program your Zaurus using the Java programming language. It provides a quick demonstration, then discusses the details of the Personal Profile and its close cousin, the PersonalJava platform. The article concludes by showing how to package a Java application for the Zaurus. Cheap Thrills Talk is cheap. This section describes how you can get some Java code running on your Zaurus quickly. Later on, I'll discuss the details. I assume you have a Java compiler handy on your desktop computer. If you don't, you should skip this section and read the rest of the article before you start writing code. Copy the following source code into a text editor and save it as HelloPP.java. (You may download the file if you wish.)
Now compile this source code with this command: javac HelloPP.java If you are using J2SDK 1.4.0, make sure to generate the older style of classfiles: javac -target 1.1 HelloPP.java If there are no errors, go ahead and run this example on your desktop: java HelloPP You should see a screen like this:
Now that The first step is to transfer the class files from your desktop to the Zaurus. You can do this any way you like. I have an 802.11 card for the Zaurus, so I just use FTP to copy the files. Alternatively, you can use the Qtopia desktop software to transfer files through the USB cradle. The files you need are HelloPP.class and HelloPP$1.class. You can put them anywhere you want on the Zaurus; I placed them in /home/root. Once you've transferred the class files to the Zaurus, use the Terminal application to open a command line. Navigate to the directory where you placed the class files. Type the following: evm HelloPP
The same design should appear on
your Zaurus. ( Understanding the Personal Profile and PersonalJava The Personal Profile (JSR 62) is a J2ME profile, a specification for a standard Java runtime environment. It is part of a software stack (see Introduction to Wireless Java Technology) designed for devices like the Sharp Zaurus and Compaq iPaq. It is built on the Personal Basis Profile (JSR 129), the Foundation Profile (JSR 46), and ultimately the Connected Device Configuration (JSR 36).
The Personal Profile is the J2ME incarnation of an older Java runtime environment, PersonalJava, which resembles the Java Development Kit version 1.1.8. PersonalJava runtime environments use a Java virtual machine1 (JVM), just as Java 2, Standard Edition does. Since the heyday of JDK 1.1.8, however, PersonalJava and J2SE have evolved separately. In terms of target device capacity, PersonalJava sits between J2SE and the CLDC/MIDP stack of J2ME. (Read Introduction to Wireless Java Technology for background information on J2ME.)
The Personal Profile software stack is built on the Connected Device
Configuration (CDC), which specifies both a virtual machine and a basic set of
APIs. The CDC is a superset of the Connected, Limited Device Configuration
(CLDC) familiar to MIDlet programmers.
It contains fundamental APIs from J2SE, including The Foundation Profile builds on the CDC, fleshing out its packages with support for socket and HTTP connection, among other things. The Personal Basis Profile adds AWT support with the exception of heavyweight components. The Personal Profile rounds out the software stack with support for AWT heavyweight components. Developing Personal Profile Applications Because the Personal Profile closely resembles the PersonalJava platform, you can use PersonalJava tools to get a quick start on Personal Profile development. Eventually Personal Profile tools will be built, but in the short term the PersonalJava tools are handy, available, and work for Personal Profile development. The J2ME Personal Profile (and the PersonalJava platform before it) includes a JVM, just as J2SE does. Consequently, Personal Profile or PersonalJava development is very similar to J2SE development. The tricky part is that the Personal Profile's set of APIs differs from J2SE's. Setting up a development environment is a matter of installing a JDK that is close to the version of Personal Profile or PersonalJava you want to use, then obtaining compatibility classes that include the APIs that the JDK lacks. Which JDK to use depends on which version of the Personal Profile or PersonalJava you prefer. The PersonalJava Web site contains a chart that explains the relationship between PersonalJava versions and JDK versions . The compatibility classes are packaged as an archive; simply add this archive to the classpath you use for compiling and testing your applications. Bear in mind that once you install the appropriate JDK and compatibility classes, many APIs may be available during development that are not actually present in a Personal Profile runtime environment. One simple example: the JDK may include the Swing user interface classes, while the Personal Profile does not. A Swing application that runs in your J2SE development environment will not run in a Personal Profile runtime environment. How do you make sure you're using only Personal Profile classes? You can check the specification as you code, but there are also some tools to help you. The PersonalJava Emulation Environment (PJEE) tool simulates a PersonalJava device. You can use this tool to test your application in an environment that complies with the PersonalJava specification. Various versions of the PJEE are available, corresponding to different versions of the PersonalJava specification, different host platforms, and different levels of support for graphic user interface. See the PersonalJava Web site for more details. Because the Personal Profile and PersonalJava environments are so closely related, you can use PJEE as a tool for developing Personal Profile applications. Another handy tool is JavaCheck. JavaCheck performs a comprehensive analysis of the class files in your application to see whether it complies with the specification. Like the PJEE, JavaCheck has different versions for the different PersonalJava specification versions. PersonalJava on the Zaurus
The Zaurus comes with a PersonalJava runtime environment already
installed, Jeode from Insignia Solutions. At the command line, Personal Profile for Zaurus Sun has created a highly tuned Personal Profile implementation for the Zaurus. To learn how to download this implementation, send an email to ppti@sun.com. You will receive an automatic response that contains instructions for downloading and installing the software. Note that this software is for evaluation only; it is not supported and cannot be used in a product. This release is for you if you are interested in the leading edge of Personal Profile technology and would like to see a high-performance, optimized implementation. To install the Personal Profile implementation for the Zaurus, follow the instructions in the email response from ppti@sun.com.
If you installed Pretty Packaging for the Zaurus
As you've seen, it's a straightforward process to install .class files on
the Zaurus and run them from the command line using
In this section I'll show you how to install a Java application in a way
that adds it to the
Zaurus's application menu.
The Zaurus knows how to install .ipk files, which are archives. The
archive is really a GZipped
The trick to packaging your application for the Zaurus is to use the right directory structure to assemble the pieces. Create the following hierarchy somewhere on your computer:
All of the class and resource files for the application should go in the home/QtPalmtop/java directory. Copy this application's two class files, HelloPP.class and HelloPP$1.class, into home/QtPalmtop/java. Next you need to tell the Zaurus how to run your application. Create the following script and save it as home/QtPalmtop/bin/run_hellozaurus. . /home/QtPalmtop/bin/installdir.sh $QPEDIR/bin/cvm -Djava.class.path=$INSTALLDIR/java HelloPP
The first line runs a script that initializes the If you want your application to look nice, you'll need an icon file. Create an icon (32x32 pixels, PNG format) or download my icon and save it as home/QtPalmtop/pics/hellozaurus.png. The next thing to create is a desktop entry file. This file tells the Zaurus how to show your application in the application menu and how to run it. Save the following file as home/QtPalmtop/Games/hellozaurus.desktop.
Notice how the desktop entyr points to the files you've already installed:
the
Finally, the application installation archive needs a control file. This is another text file that contains some simple information about the archive. Save the following text as control, in the same directory as home.
Building the archive is straightforward if you have tools
that create .tar and .gz files. Linux, Solaris, Mac OS X and
other Unix-like operating
systems include
Installing Your Application Once you create the application archive, it's a simple matter to install it:
Running the application is now a simple matter of choosing the Games tab and tapping on the HelloZaurus icon. Summary By now you have a solid understanding of both the Personal Profile and the PersonalJava platform. You can develop Personal Profile applications and package them for the Sharp Zaurus. The world is yours for the taking. 1 As used in this article, the terms "Java virtual machine" or "JVM" mean a virtual machine for the Java platform. Back To Top | ||||||||||||||||
|
| ||||||||||||