My OpenBSD 3.9 java port notes. For more information, see the ports portion of the OpenBSD FAQ.
Installing Java 1.4
- Insert OpenBSD CD #3 (source code), and copy the ports source code to the /usr/ directory.
$ mkdir -p /cdrom $ mount /dev/cd0a /cdrom/ $ cd /cdrom $ cp ports.tar.gz /usr/
- Extract the ports source code.
$ cd /usr/ $ tar -zxvf ports.tar.gz
- Install the java 1.4 port. Note that this and the following steps may take a very long time (hours).
$ cd /usr/ports/devel/jdk/1.4 $ make
- Notice the following build errors. It is telling us to go off and manually download some files.
*** You must manually fetch the distribution files, place *** them in /usr/ports/distfiles and then run make again. *** Get the SCSL source & binary files: *** j2sdk-1_4_2-src-scsl.zip *** j2sdk-1_4_2-bin-scsl.zip *** from http://wwws.sun.com/software/communitysource/j2se/java2/download.html *** Get the BSD patchset file: *** bsd-jdk14-patches-7.tar.gz *** from http://www.eyesbeyond.com/freebsddom/java/jdk14.html *** Get the linux binary sdk file: *** j2sdk-1_4_2-linux-i586.bin *** from http://java.sun.com/products/archive/j2se/1.4.2/ *** Error code 1 Stop in /usr/ports/devel/jdk/1.4 (line 2102 of /usr/ports/infrastructure/mk/bsd.port.mk). *** Error code 1 Stop in /usr/ports/devel/jdk/1.4 (line 1561 of /usr/ports/infrastructure/mk/bsd.port.mk). *** Error code 1 Stop in /usr/ports/devel/jdk/1.4 (line 1750 of /usr/ports/infrastructure/mk/bsd.port.mk).
- Download the following four files and place them in the /usr/ports/distfiles/ directory. You will need to create a free sun online account to downlowd some of these files if you don’t already have one.
- Download the SCSL source (j2sdk-1_4_2-src-scsl.zip) from Sun
- Download the SCSL binary (j2sdk-1_4_2-bin-scsl.zip) from Sun
- Download patchset 7 (bsd-jdk14-patches-7.tar.gz) from the BSD Java Port Site
- Download the 1.4 SDK linux binary (j2sdk-1_4_2-linux-i586.bin) from Sun
- Try building java again, and notice the next error. It is telling us to go off and manually download one more file.
$ cd /usr/ports/devel/jdk/1.4 $ make *** You must fetch the distfile for this port manually *** after agreeing to the license agreement at *** *** http://java.sun.com/j2se/1.3/download.html or *** http://java.sun.com/products/archive/ *** *** Choose the * Linux self-extracting file option and place *** j2sdk-1_3_1_16-linux-i586.bin into /usr/ports/distfiles. *** Error code 1 Stop in /usr/ports/devel/jdk/1.3-linux (line 2102 of /usr/ports/infrastructure/mk/bsd.port.mk). *** Error code 1 Stop in /usr/ports/devel/jdk/1.3-linux (line 1561 of /usr/ports/infrastructure/mk/bsd.port.mk). *** Error code 1 Stop in /usr/ports/devel/jdk/1.3-linux (line 1750 of /usr/ports/infrastructure/mk/bsd.port.mk). *** Error code 1 Stop in /usr/ports/devel/jdk/1.4 (line 1422 of /usr/ports/infrastructure/mk/bsd.port.mk).
- Download the following file and place it in the /usr/ports/distfiles/ directory.
- Download the 1.3 SDK linux binary (j2sdk-1_3_1_16-linux-i586.bin) from Sun
- Try building java again, and wait… for hours until it is done.
$ cd /usr/ports/devel/jdk/1.4 $ make $ make install To use the Java plugin with Mozilla or Mozilla-firefox you must create a symbolic link from /usr/local/jdk-1.4.2/jre/plugin/i386/ns610/libjavaplugin_oji.so to your local Mozilla plugins directory, which is found at ~/.mozilla/plugins/ or to the shared Mozilla plugins directory, which is found at /usr/local/lib/mozilla-plugins/ $ make clean $ make clean=depends
- Unmount and eject OpenBSD CD #3.
$ umount /cdrom/
Testing the Install
- Place the following code in /usr/local/jdk-1.4.2/bin/HelloWorld.java.
public class HelloWorld { public static void main(String args[]) { System.out.println("Hello World!"); } }
- Compile HelloWorld.java into HelloWorld.class.
$ ./javac HelloWorld.java $ ls HelloWorld* HelloWorld.class HelloWorld.java
- Execute HelloWorld.
$ ./java HelloWorld Hello World!
- Currently you would have to place all your java files in /usr/local/jdk-1.4.2/bin/ or type /usr/local/jdk-1.4.2/bin/javac and /usr/local/jdk-1.4.2/bin/java rather than simply javac and java. To fix this, add /usr/local/jdk-1.4.2/bin to the PATH variable in the .profile file in your home directory. This change will not take until the next time you login.
$ echo $PATH /home/diana/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin :/usr/local/sbin:/usr/games:/usr/local/jdk-1.4.2/bin:.
Installing Java 5
- Similar to the above instructions on installing java 1.4, but it’s a different ports directory, and there are different files to download first.
$ cd /usr/ports/devel/jdk/1.5 $ make $ make install $ make clean $ make clean=depends