Java 2 SDK 1.4 on OpenBSD
Requirements
You will need OpenBSD/i386 3.6 release or later to build and run the 1.4 JDK. At least 448M of virtual memory (real + swap) is needed to build the JDK. More may be needed depending on what else is running on the build system. Having less then 256M real memory will increase the already long build time. You will also need approximately 1.7GB of free disk space in build area.
Licensing
You will need to agree to the Sun Community Source License (SCSL) to be able to download many of the needed distfiles. The resulting binaries created from the 1.4 port are licensed under the SCSL and have restrictions on use and distribution. No compatibility testing (TCKs) have been performed on the JDK for OpenBSD.
Distfiles
You will need to manually fetch four distfiles for the 1.4 port and one distfile for the 1.3-linux port which is a build depend.
First you will need to download the Java 2 SDK 1.4.2 SCSL Source and the SCSL Binaries (j2sdk-1_4_2-src-scsl.zip and j2sdk-1_4_2-bin-scsl.zip).
Once you have done this and agreed to the SCSL you can download the latest BSD JDK 1.4.2 patchset (bsd-jdk14-patches-X.tar.gz). Patchset 7 or greater is required for OpenBSD support.
Lastly you will need to download the first release of 1.4.2 Linux binary SDK (j2sdk-1_4_2-linux-i586.bin) and the latest 1.3.1 Linux binary SDK (j2sdk-1.3.1_XX-linux-i586.bin). Note: sometimes the latest 1.3.1 Linux binary SDK becomes out of sync with the 1.3-linux port. If this should happen you can download the previous releases here.
Put all five distfiles into /usr/ports/distfiles.
Building and Installing
For 3.6 release/stable download the port here. Extract as follows:
$ cd /usr/ports/devel/jdk/
$ tar xzf jdk14.tar.gz
$ cd 1.4
For 3.7 and later the port is at /usr/ports/devel/jdk/1.4.
Consider installing the build and run depends from packages to save time and disk space. Here's an example of how to do that for 3.6 (for other releases adjust package versions as needed):
$ PKG_PATH=ftp://closest.mirror.openbsd.org/pub/OpenBSD/3.6/packages/i386
$ export PKG_PATH
$ sudo pkg_add gtar-1.14.tgz nspr-4.4.1.tgz gmake-3.80.tgz unzip-5.51.tgz zip-2.3p0.tgz iodbc-2.50.3.tgz openmotif-2.1.30.5.tgz ghostscript-fonts-6.0.tgz redhat_base-8.0p4.tgz
Increase your data limit to 448 megabytes and stack limit to 8 megabytes. The commands for this are different based on your shell. For ksh(1), zsh(1) and bash(1):
$ ulimit -dS 448*1024
$ ulimit -sS 8*1024
or for csh(1) and tcsh:
$ limit datasize 448m
$ limit stacksize 8m
NOTE: The 'default' login class can not change the data limit to 448 megabytes. If you are unable to increase your data limit to 448 megabytes, then use vipw(8) to change your login class to 'staff' or adjust your current login class in login.conf(5).
Build the packages:
$ SUDO=sudo make package 2>&1 | /usr/ports/infrastructure/build/portslogger .
After several hours two packages will be created, one for the JDK and one for JRE.
To install the JDK:
$ SUDO=sudo make install
To install the JRE:
$ SUDO=sudo SUBPACKAGE=-jre make install
Optionally, you can uninstall the build depends. Here's an example for 3.6:
$ sudo pkg_delete gtar-1.14 nspr-4.4.1 gmake-3.80 unzip-5.51 jdk-linux-1.3.1_12 redhat_base-8.0p4 libiconv-1.9.1 gettext-0.10.40p1 bzip2-1.0.2
Running
To use the JDK or JRE you will likely need to increase your limits as described in the Building and Installing section above. Adjusting limits in login.conf(5) for your login class is the best way to ensure java has the resources it needs.