ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Java Development Kit for FreeBSD

by Justen Stepka

Over the last several years, Java has gained huge momentum and matured into an excellent server-side language because of the following advantages:

  • Industry commitment
  • Security and encryption services
  • Reliability
  • Performance
  • Scalability
  • Distributed programming models

Several of us have taken this initiative one step further and have embarked on the path to certify a build of the Java Development Kit (JDK) for FreeBSD. In this article, we will look at the path taken by these individuals, the different installation options, and how to compile and install a native version of the 1.3 JDK.

The first life signs of a FreeBSD-native JDK appeared in early 1998 with the release of the 1.1.6 JDK. Steady progress by one to two developers at any given time brought us a mid-1999 release of the 1.1.8 JDK. With the first stable JDK in place, development quickly shifted to supporting the Java2/1.2 JDK, with an alpha test release in May 2000. By October of that year, the team reached a stable point, and the 1.2 JDK was placed into the ports collection. The Java ports collection was growing rather quickly at this point, and the spotlight turned to starting the development of the 1.3 JDK in early 2001.

In December 2001, the FreeBSD Foundation announced that it had secured a license from Sun to distribute a native version of the JDK and Java Runtime Environment (JRE).

"The availability of a FreeBSD JDK license will benefit both the users and the developers of FreeBSD," claimed a statement from the foundation at the time. "As Java continues to grow in popularity, more and more software packages require it. With an officially licensed Java Development Kit, FreeBSD will gain better acceptance as the right choice of operating system for Java-based projects."

Current development efforts are well underway, thanks to Greg Lewis, who is pushing the active development of 1.3.1 to meet the Java Compatibility Kit (JCK), so that a finalized version of the JDK and JRE can be distributed freely.

Unfortunately, there is no timeline for when JDK/JRE will meet the requirements for the Java Compatibility Kit. The current team is working hard to meet the compilation and runtime JCK requirements, and have been providing updates to the FreeBSD-Java mailing list.

In the meantime, there are several options for setting up and running Java on your own FreeBSD system. Looking into the Java category, you will see several options for running a VM:

  • FreeBSD 1.1.8 JRE
  • FreeBSD 1.1.8 JDK
  • FreeBSD 1.2 JDK
  • FreeBSD 1.3 JDK
  • Linux Blackdown 1.3 JDK
  • Linux IBM JDK
  • Linux 1.4 JDK
  • Linux 1.3 JDK
  • Linux 1.2 JDK

You will need to pick the version of the VM that meets your needs and system requirements and proceed from there. While working with the Linux distributions will give you certified VM, remember that all operations will be running in Linux-compatibility mode. The FreeBSD situation is not without its own problems, though. The native ports currently do not support Just In Time (JIT) compiling. There are, however, a few alternatives to support JIT, such as ShuJIT and OpenJIT. Both of these are available via the ports collection. One deciding factor is if you will need the graphics system of Java. If you wish to work with these types of applications, a Linux JDK is advisable. The native graphical support in FreeBSD is lagging due to the fact that most users are interested in server-side development with tools such as Tomcat, JBoss, and Orion Server.

For this article, we will be installing the FreeBSD 1.3 JDK with the FreeBSD ports collection.

Before we start with the installation of the 1.3 JDK, you will want to download the latest version of the ports collection. You can upgrade your ports collection by using CVSup. If you need assistance upgrading your ports system, please read the CVSup documentation.

The FreeBSD JDK 1.3 port is located in /usr/ports/java/jdk13/.

The current list of dependencies is substantial:

  • XFree86-libraries
  • Expat
  • Freetype
  • Gettext
  • Glib
  • Gmake
  • Gtar
  • Gtk
  • Imake
  • Javavmwrapper
  • Libiconv
  • Linux-jdk-1.3
  • Linux_base
  • M4
  • Nspr
  • Open-motif
  • Pkgconfig
  • Urwfonts

Yikes! You will unfortunately need all of these.

The XFree86-libraries are used to build the graphical system of the JDK, and there is no way around this. The Linux_base and Linux 1.3 JDK must be installed, as they are used to bootstrap the native build.

To accomplish the build, you will need to venture outside of the traditional build process and download several files externally, due to Sun license restrictions. You will need the following additional files:

Each of these files needs to be placed in /usr/ports/distfiles. With the necessary installation files downloaded, you are now ready to start the automatic build process. Simply type:

make install
make clean

This process will take you through the build and installation of all necessary ports to build and install the native 1.3 JDK. With the build finished, you are now ready to test your installation:

cd /usr/local/jdk1.3.1/bin/
javac -version

The output should be similar to the following:

java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
Classic VM (build 1.3.1_02-b02, green thread, nojit)

When you are sure that everything is in place, you are ready to delete the build by typing the following:

cd /usr/ports/java/jdk13
make clean

Everything is now in place, and you are now ready to start thinking about which Java applications you want to run on your FreeBSD system; the Java ports collection had over 108 entries. A good place to start looking next would be installing a JIT complier for the VM, or setting up an application server such as Tomcat, JBoss, or Orion. All of these applications are available in the ports system.

Justen Stepka is an enterprise system architect for Digital JWT Minneapolis (http://www.digital.jwt.com/)

Return to ONJava.com.