Java for Linux @ JDJ
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.
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.
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.
You can download Java Developer Kits for Linux from IBM (Java" />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:
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).
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.
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.
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.
Netbeans Java IDE: www.netbeans.com/