Java

From GumstixDocsWiki

Jump to: navigation, search

Java is available for application-level programming on the Gumstix. With a few exceptions, the Gumstix Java stack is conformant to the Java 5.0 spec.

As Sun does not provide a Java implementation for ARM Linux, we use an open source alternative.

Contents

Quickstart

To get Java support in your flash filesystem, follow these easy steps.

  1. If you haven't already, check out a copy of the Buildroot.
  2. Ensure that you have one of the following JVMs installed gcj, jikes, kjc, ecj or gcjx
  3. Add the necessary packages to your Buildroot.
    1. Enable JamVM, an open-source Java Virtual Machine implementation.
    2. Enable Classpath, an open-source implementation of the Java standard libraries.
    3. Enable zlib.
  4. Build and install the filesystem.
  5. Copy over your Java classfiles or JARs.
  6. Have fun!

Note that JamVM and Classpath will add about 7MB to your root filesystem. Thus, this approach is only suitable for the XM line of Gumstix modules, with 16MB of Flash (and enough space available alongside your other data).

JamVM

Currently, the most popular option for Java on the Gumstix is JamVM, an open-source Java virtual machine. It's also the easiest, as it's available from the standard Gumstix Buildroot.

JamVM is an interpreted-mode JVM, so it will not achieve the high performance of a modern just-in-time-compiled JVM (like IBM's J9). However, it has the distinct advantage of being free, and is available for the ARM/Linux environment used on the Gumstix.

Fortunately, JamVM supports the standard JNI interface for linking in libraries written in other languages, which allows you to write performance-critical portions in C or C++. JamVM also allows you to use libraries that conform to the JNI spec, such as RXTX for serial communication.

While not as fast as pure C code, JamVM has been successfully used on the Gumstix for high-level control and rudimentary vision processing (using a CMUcam2 camera). Specific performance information can be found on the Java performance page.

Classpath

GNU Classpath is an open-source implementation of the Java standard libraries, and is available in the standard Gumstix Buildroot. When installed with JamVM, it provides most of the functionality of any other Java 5.0 system. (A few methods and classes appear to be missing at this writing.)

Bluetooth Java API

If you just need to send and receive data over rfcomm to the same end device, put a binding in /etc/bluetooth/rfcomm.conf and you'll be able to open the /dev/rfcommX file and do normal I/O. You may even be able to call out to executables like sdptool or hcitool to do short operations.

If you need more advanced stuff like direct L2CAP connections and making connections on the fly, you will need a library. The Avetanabt JSR-82 library seems to be one of the few things being maintained. Search for ( java bluetooth) at sf.net for the list of related projects.

Third-party libraries

Other off-the-shelf Java libraries and components will work with JamVM on the Gumstix. A specific list is available in the Java libraries section such as VOYAGER Edge, the Intelligent Mobile Agent Platform.

Troubleshooting

On Ubuntu 8.04, buildroot produces the following error after selecting the JamVM, Classpath, and zLib packages.

configure: cannot find javac, try --with-gcj, --with-jikes, --with-kjc, or --with-gcjx

Resolved the problem by installing jikes:

sudo apt-get install jikes
Personal tools