HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

Two technologies that have gained widespread interest and support in the past few years are Java and Linux. Until recently, however, the two were separate, although they share similar visions of open, ubiquitous computing. As interest in both Java and Linux solutions increases, developers are naturally looking to combine the two, and want to write applications in Java that run on Linux systems. But they need stable, fast and fully functional JVMs, especially for server solutions that require servlets and support for Java Server Pages.

Several independent efforts to port JVMs to Linux are in progress, including those by IBM, Sun Microsystems, the Blackdown Java-Linux Porting Team headed by Steve Byrne and the Kaffe group headed by Tim Wilkinson. The IBM and Blackdown ports are based on code licensed from Sun, while Kaffe is a "cleanroom" implementation. Ports based on Sun code are complicated - and frequently delayed - by licensing issues. While IBM has an industry license for Java technologies, the Blackdown group had to make special licensing arrangements to obtain the Java 2 JVM source code. Sun's Community Source Code License may eventually make it easier to resolve these licensing issues, although the prevailing opinion within the Linux community seems to favor the GNU Public License.

Current JVMs for Linux
Sun currently supports reference implementations of JDK 1.1 and JDK 1.2 (now called Java 2 SDK) for Solaris and for Windows 95 and NT. Also available are highly optimized production versions for Solaris and Windows. At the JavaOne Developer's Conference this past June, Sun announced a restructuring of the Java APIs and specifications into the Java 2 Micro Edition for handheld and embedded applications, the Java 2 Standard Edition for workstation applications and the Java 2 Enterprise Edition for server applications.

The Micro Edition, for example, excludes some libraries - such as the AWT classes - that aren't needed for embedded systems and handheld devices. The Enterprise Edition targets server application development and supports Enterprise JavaBeans classes. The Java for Linux efforts now in progress target the Standard Edition, which includes the Java Foundation Classes.

Available Linux JVM ports are all based on the "Classic" JVM reference code and don't include any of Sun's HotSpot or other performance-enhancement code.

IBM's port is an early-access release of the 1.1.8 JVM, and includes a JIT compiler and support for native threads. Linux users who have worked with this JVM report good performance and stability. IBM is reportedly working on a Java 2 port, but they correctly observe that there is still much demand for 1.1 applications and that 1.2 isn't widely used yet.

The Kaffe JVM, included with some Linux distributions, is a cleanroom implementation of the 1.1 JVM specification. But the most recent release, 1.0b4, doesn't include RMI support and is missing several crucial security features such as bytecode verification and observance of "private" modifiers. Tim Wilkinson, who leads the Kaffe effort, says several improvements are in progress, including a significantly faster JIT compiler and support for the Java 2 Collections API.

The Blackdown ports of the 1.1 and 1.2 JDKs are probably the best-known implementations for Linux. Led by Steve Byrne, a former Sun employee, the team has been working on a fully JCK-compliant 1.2 JVM for nearly a year. The current "prerelease" is fairly complete and stable, and includes a JIT compiler.

Sun has provided some engineering support to the Blackdown group for JDK ports, and has even worked with several Linux distributors such as RedHat to help port Linux itself to UltraSPARC systems.

Linux developers would like to see Sun provide a supported reference implementation of the Java 2 SDK, but Sun has made no announcements about its plans for supporting Java on Linux.

Java Programming on Linux Systems
You can download Java Developer Kits for Linux from IBM (www.ibm.com/java) and Blackdown (www.blackdown.org). Installation consists of uncompressing the downloaded file and extracting the component files and directories. Linux includes utilities for uncompressing ZIP files and other compression formats. The Blackdown distribution file jdk1.2pre-v2.tar.bz2 is compressed with the bzip2 program. To extract and install the files, use these two commands:

bzip2 -d jdk1.2pre-v2.tar.bz2
tar xvf jdk1.2pre-v2.tar

After you install the files in a directory, you need to set your PATH environment variable so your command shell can find the javac compiler, the java runtime program and other Java utility programs. Also, if you plan to use third-party Java libraries, you must set your CLASSPATH environment variable to include the directory location of those libraries. For example, I set my Java environment variables for my command shell, ksh, like this:

export PATH=/usr/local/java/bin:$PATH
export CLASSPATH=/home/hfoxwell/MyJava

Test your installation by entering "java - version" from your command line. The JVM should start up and report "java version 1.2" or something similar. If you're testing more than one JDK, be sure to set your PATH and CLASSPATH explicitly for each version that you plan to use (see Figure 1).

Figure 1
Figure 1:

Linux JVMs typically require a "glibc" C library in order to run. Check the Release Notes for your JVM to determine which version of this library is required. Most current Linux distributions ship with one or more versions of "glibc". The Blackdown 1.2 JDK requires "glibc2", also called "libc6", and is found at "/lib/libc.so.6".

All of the current Linux JVM offerings are unsupported beta or early-access releases. As such, they are incomplete, buggy and not fully optimized for performance. The Blackdown 1.2 JVM doesn't have a working native threads module yet, and the IBM port is missing some IO exceptions. Moreover, important extension APIs, such as Java 3D, Advanced Imaging, and Sound, aren't yet ported to Linux. Sun has provided source code for these to IBM, Blackdown and other licensees, but it may be a while before you see these APIs on Linux.

Java Development Tools for Linux
At JavaOne several vendors announced plans to provide developer tools for Linux, including IBM, Inprise and MetroWerks. Blackdown's Web site includes an extensive "Java Tools for Linux" link that lists IDEs and other programs for Java developers. If you're familiar with "Emacs", have a look at "emacs-JDE" at www.sunsite.auc.dk/jde/. If you'd like a full-featured, drag-and-drop IDE, try NetBeans from www.netbeans.com/ (see Figure 2). NetBeans is written in Java and runs nicely on Linux using the Blackdown 1.2 JVM. It supports development in Java 1.1 or 1.2, and is distributed in a free personal-use version as well as a commercial, enterprise development version.

Figure 2
Figure 2:

Conclusion
Open source advocates have raised the awareness of Linux as a stable, richly featured operating system. They're also attracted to Java's platform-independent programming model and to the new solutions it enables, such as Jini, Enterprise JavaBeans and JSPs.

As Linux JVMs from Sun, Blackdown, IBM and others become more stable, complete and competitive, Linux developers will be able to contribute their considerable expertise to the widespread deployment of Java technologies.

URL Resources

  1. GNU Public License: www.fsf.org/copyleft/gpl.html
  2. IBM's Java for Linux: www.alphaworks.ibm.com/tech/linuxjvm
  3. Blackdown Java-Linux Porting Team: www.blackdown.org/
  4. Netbeans Java IDE: www.netbeans.com/
  5. Kaffe: www.kaffe.org/
  6. Metrowerks CodeWarrior for Linux: www.metrowerks.com/desktop/linux/
  7. Sun's Linux information site: www.sun.com/linux
Author Bio
Harry Foxwell is a systems engineer for Sun Microsystems' Southern Area, responsible for technical consulting and education on Java and network computing. Harry has worked with Java since its introduction in 1995, and is a contributing author to Introduction to Programming Java Applets, Java Core Libraries and Java for Managers, instructional CDs published by MindQ. He also maintains Sun's internal Web site of Linux information.
He can be reached at: [email protected]
 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.