Java Development On NetBSD

The Tools

The Build System

My Java build system on NetBSD/i386 consists of a /usr/java sub-tree (actually a link from the JDK home dir in use to /usr/java ) and a 4.4BSD style make include file .

A good starting point for the exploration of make (besides 'man make') is the make tutorial in /usr/share/doc/psd/12.make/ .

The Directory Structure

In analogy to the Un*x-derived directory structure, all the Java libraries (*.jar, *.zip) are located in /usr/java/lib :

[hf@scree] ~ > l /usr/java/lib/*.{jar,zip}
-r--r--r--  1 root  wheel   200486 Mar 16 17:17 /usr/java/lib/
-r--r--r--  1 root  wheel    68926 Mar 16 17:17 /usr/java/lib/
-r--r--r--  1 root  wheel    64965 Mar 16 17:28 /usr/java/lib/
-r--r--r--  1 root  wheel  8876583 Mar 13 15:47 /usr/java/lib/
-r--r--r--  1 root  wheel   217529 May 25 12:18 /usr/java/lib/collections.jar
-r--r--r--  1 root  wheel   128722 May 15 12:40 /usr/java/lib/interclient.jar
-r--r--r--  1 root  wheel   200265 Mar 16 17:17 /usr/java/lib/
-r--r--r--  1 root  wheel  1045782 Mar 16 17:28 /usr/java/lib/jgl.3.0.jar
-r--r--r--  1 root  wheel   963513 Mar 16 17:16 /usr/java/lib/jgl.3.1.jar
-r--r--r--  1 root  wheel  2001666 May 14 17:15 /usr/java/lib/swingall.1.0.2.jar
-r--r--r--  1 root  wheel  1907130 Mar 16 17:16 /usr/java/lib/swingall.1.0.jar
[hf@scree] ~ > 

The Java home environment variable of the week (try JAVA_HOME, JAVAHOME, JDK_HOME, JDKHOME) points to /usr/java. The CLASSPATH variable remains unset, saving you a lot of trouble; the Makefiles do the dirty work for you. PATH contains /usr/java/bin.

The library filenames are mapped to symbolic names (like LIBJXXX) in the Java make include file.

The Java make(1) include file

The 4.4BSD Java make include file offers a variety of variables that control the build system. They are set to default values and can be overridden in local Makefiles.

A typical Makefile shows the most important variables:

(Don't forget to .include <> at the end of your Makefile.)

The following targets are defined:

The Portability

NetBSD's make compiles with minor tweaks on Windows NT under the Cygnus GNU-Win32 package (see NetBSD PR bin/4905 & 4908). Add _PS= ; to /etc/mk.conf to use the Win32 specific path separator. Fortunately, Sun's JDK-Win32 accepts slashes as file separator.

'make all' works fine that way; currently, 'make depend' chokes on what I think is a bash/GNU-Win32 deficiency.

The Experiences

The described system works reliably in a project with ~150 files. Compile times are much larger than with JBuilder 1.0.1 on NT 4, but we spend a lot of time on searching errors and rebuilds from scratch because of JBuilder's insufficient dependency checking (AFAICS, this applies to the JDK javac's dependency checking as well).

Last modified: Sun Nov 28 17:51:34 CET 2004