February 05, 2006
Java on OpenBSD 3.8

The developers of OpenBSD do not provide binaries or simple to install packages of Java because this language contains proprietary (that is, not open source) code. The code can not be audited by the OpenBSD standards and may contain security problems. Consquently, getting this installed and working on an OpenBSD system requires building Java from sources. This is a real problem.As I looked through the documentation and got this accomplished, I found that there was no complete guide to this, for a total n00b like me. There are two how-to's I found that are close, this one which is nearly correct, and this one, which has an error or two.

I am using -current OpenBSD 3.8, downloaded from their mirrors 12/23/05. After install, you need to set up the ports tree from the CDROM sources as described in the OpenBSD FAQ on this topic. After this is done, you will find the Makefile for Java SDK 1.4.2 in the /usr/ports/devel/java/sdk/1.4/ directory.

Before attempting to compile Java 1.4.2 you need to install certain needed packages:

PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/3.8/packages/i386/
export PKG_PATH
sudo pkg_add autoconf-2.59.tgz
sudo pkg_add gettext-0.10.40p3.tgz
sudo pkg_add ghostscript-7.05p3.tgz
sudo pkg_add ghostscript-fonts-6.0.tgz
sudo pkg_add gmake-3.80p1.tgz
sudo pkg_add gtar-1.15.1p2.tgz
sudo pkg_add iodbc-2.50.3.tgz
sudo pkg_add libtldl-1.5.18.tgz
sudo pkg_add libtool-1.5.18p2.tgz
sudo pkg_add nspr-4.4.1.tgz
sudo pkg_add openmotif-2.1.30.5p0.tgz
sudo pkg_add redhat_base-8.0p5.tgz
sudo pkg_add unzip-5.52.tgz
sudo pkg_add zip-2.3p0.tgz

Install as many of these from packages as possible. During the compile, if some are not present (e.g., libtldl) they will install from ports along with dependencies (e.g., libtool) which will fail due to incompatibilities. Others (openmotif, iodbc) seem to build from ports ok. One other needed file is zcrypt29.zip which is downloaded and built during the build.

Next, you need to go the Sun's site and get the source files. Go to http://www.sun.com/software/communitysource/j2se/java2/download.xml and register with Sun then download the Java 2 SDK 1.4.2 SCSL Source file j2sdk-1_4_2-src-scsl.zip and SCSl binary file j2sdk-1_4_2-bin-scsl.zip.

While at Sun's site, you also need to got to http://java.sun.com/products/archive/j2se/1.4.2/ and download the Java 2 SDK for 1.4.2 j2sdk-1_4_2-linux-i586.bin and then go to http://java.sun.com/products/archive/index.html to pick up the Java SDK for 1.3.1 j2sdk-1_3_1_16-linux-i586.bin. Yes, you need both 1.4.2 and 1.3.1 binaries. Also, you need version 16 of the 1.3.1 binary - the make wil choke on the latest version.

Then, go over to http://www.eyesbeyond.com/freebsddom/java/JDK14SCSLConfirm.html and get patchset 7, bsd-jdk14-patches-7.tar.gz. The makefile looks for version 7 and will not run with the latest patchset 8.

Now, put all these files into /usr/ports/distfiles (make the directory if it doesn't exist). They do not need to be expanded or installed in any way - leave them in their compressed form as downloaded.

Before you build Java, be sure you have lots of disk space. At the end of make && make install, the build files use up over 1.9GB. I created a temporary build space by copying /usr/ports/devel/jdk/1.4/ to /home/tmp/ (where there was plenty of space) and creating a symbolic link. Now cd /usr/ports/devel/jdk/1.4/. Type sudo make and, on a slow computer, come back in 5-8 hours. After the make has completed, type sudo make install.

After all this is done, the plugin is found as /usr/local/jdk-1.4.2/jrs/plugin/i386/ns610/libjavaplugin_oji.so. To install for you, mkdir ~/.mozilla/plugins and ln-s /usr/local/jdk-1.4.2/jrs/plugin/i386/ns610/libjavaplugin_oji.so ~/.mozilla/plugins or, for all users, sudo mkdir /usr/local/lib/mozilla-plugins and ln -s /usr/local/jdk-1.4.2/jrs/plugin/i386/ns610/libjavaplugin_oji.so /usr/local/lib/mozilla-plugins.
To check if the Java plugin has been installed in your Firefox or Mozilla browser, enter "about:plugins" in the URL bar and see. Now, clean up by running cd /usr/ports/devel/jdk/1.4/ and sudo make clean. You can also remove any packages used in the build, if space is an issue.

If you don't want to build it yourself, here's on bulit with 3.8 release, using the above method. Place it in /usr/local/lib/mozilla-plugins/. Works for me.

Posted by Gordon at February 05, 2006 06:36 PM | E-mail Author