At this point, I believe JDK 1.5.0 (jdk15), as provided by the diablo-jdk15 binary available from The FreeBSD Foundation's Java Downloads Page, is fine for everyday use. The java apps I run, at least, all seem happy with that java environment. To install diablo-jdk15, visit the link I just gave, then scroll down to the "Packages" section, and choose the "Diablo JDK" download that matches, as closely as possible, your platform/architecture. (If you wanted to install diablo-jdk15 on FreeBSD 6.2, i386, you would download the "FreeBSD 6.1/i386" version). Agree to the license agreement and download the file. Then, in a terminal window, su to root and:
pkg_add diablo-jdk-freebsd6.i386.1.5.0.07.01.tbz
Add the path to where you downloaded the diablo-jdk15 package, if you downloaded it to somewhere other than your home directory, to the above command if necessary. Before the installation completes, you'll be prompted with a license agreement, and after scrolling through it you'll have to type the word "yes" into the terminal and hit 'Enter' to finish the install.
It is possible to upgrade diablo-jdk15 using portupgrade. Just follow the instructions output in the error message, if any. For example, the first time you upgrade the diablo-jdk15 package, you'll need to download the Time Zone Updater file from Sun (if you're in the USA or Canada--otherwise you can set the option WITHOUT_TZUPDATE=yes in /etc/make.conf as to my knowledge your government has not recently altered Daylight Saving Time). You can get that file by going to Sun's Java Downloads Page and following the link for "JDK US DST Timezone Update Tool." Note that you will be forced to login to your Sun Downloads account (or create one--it's free) in order to download the file. Note that you will have to move the downloaded file to /usr/ports/distfiles/ before you can upgrade diablo-jdk15.
With installing diablo-jdk15 being so easy, you might ask "why would I want to install jdk14?" Some users will no doubt have their reasons. In the past we've noticed that some java applications don't behave under jdk15, making it necessary for us to continue running jdk14, but that no longer appears to be the case. I've now been running diablo-jdk15 exclusively with very good results. (It is worth noting that you can have jdk14 and jdk15 installed simultaneously, but this may require specifying which java version you want to use when compiling or running certain java apps). Unfortunately, you cannot get binary packages for jdk14 (The FreeBSD Foundation only paid Sun for a license to distribute jdk15 in binary form), so we need to compile jdk14 on our own from source. Due to Sun's licensing restrictions, we have to manually download several files from Sun's website in order to do so.
If you're in the USA or Canada, you'll need to download the Time Zone Update Tool from Sun. It's the same file I gave you the download link to above. (Yes the same file works for either jdk14 or diablo-jdk15). Once you've obtained that file, you can follow the rest of these instructions for obtaining the files needed to build jdk14.
Because navigating Sun's website can be a bit confusing (the files we need to download are in different places, preventing us from simply downloading them all at once), we're going to walk you through the entire process of getting the necessary files and compiling jdk14. Please note that the following images of Sun's website were taken without Sun's permission and will be removed upon request.
First, go to http://www.sun.com/software/communitysource/j2se/java2/download.xml
Click on "Download(SCSL Source)" under "Java 2 SDK 1.4.2"
Log into your Sun account (it's free to register if you don't have an account). If Firefox asks, you could always tell it to remember your password for this site to save the hassle of having to log in again in the future.
Click "Accept License Agreement"
Click on the "1.4.2" link that appears under "Java(TM) 2 SDK, Standard Edition (SCSL) 1.4.2"
Click on "j2sdk-1_4_2-src-scsl.zip" to download it.
Now, go back to http://www.sun.com/software/communitysource/j2se/java2/download.xml
Click on "Download (SCSL Binaries - needed to complete source build)" under "Java 2 SDK 1.4.2"
Either log in or, if you told Firefox to save your password, you'll be taken to the license agreement. Click "Accept License Agreement"
Click on the "1.4.2-bin" link that appears under "Java(TM) 2 SDK, Standard Edition (SCSL) 1.4.2"
Click on "j2sdk-1_4_2-bin-scsl.zip" to download it.
Click "Accept License Agreement". (You may have to scroll down to find this link).
After the page reloads, scroll down until you find the "Linux Platform - Java(TM) 2 SDK, Standard Edition 1.4.2_10" heading
Click on "self-extracting file" under Linux Platform - Java(TM) 2 SDK, Standard Edition 1.4.2_10 to download it.
Now, go to http://www.eyesbeyond.com/freebsddom/java/jdk14.html
Click on "download the latest BSD JDK 1.4.2 patchset"
Make sure "Patchset 7" (or a later version) is displayed, then click "ACCEPT" to download it.
Now that we have the necessary files, open up a terminal window and su to root. Then, put the downloaded files into /usr/ports/distfiles/ (obviously if you downloaded a more recent patchset than 7, the file name will be slightly different than the example below):
mv bsd-jdk14-patches-7.tar.gz j2sdk-1_4_2_10-linux-i586.bin j2sdk-1_4_2-bin-scsl.zip j2sdk-1_4_2-src-scsl.zip tzupdater-1.1.0-2007c.zip /usr/ports/distfiles/
Note: we need to have java in order to get java. Sounds kind of counterintuitive but apparently Sun used the java language to write parts of the Java Development Kit. (Don't worry, one of the files we downloaded was the linux binary of jdk14. We're going to use this temporarily in order to install jdk14 natively on FreeBSD).
We need to have linprocfs and linux binary compatibility enabled. If you do not already have these, do the following:
kldload linux
kldload linprocfs
This loads the linux.ko and linprocfs.ko kernal modules. Just be be safe, we can check to see if we have these modules loaded:
kldstat
You should see something like this:
fongsaiyuk% kldstat
Id Refs Address Size Name
1 10 0xc0400000 4a2f80 kernel
2 16 0xc08a3000 568dc acpi.ko
3 1 0xc1cc2000 6000 linprocfs.ko
4 1 0xc1d53000 15000 linux.ko
You may very well have additional kernel modules loaded, but so long as you have "linprocfs.ko" and "linux.ko" loaded, you're okay for our purposes.
Once you've loaded these kernel modules,
mount -t linprocfs linprocfs /compat/linux/proc
Now it's finally time to install java:
cd /usr/ports/java/jdk14
make install clean
It may take a few hours to compile, assuming your build isn't interrupted by any errors.
Now that we've installed jdk14, we no longer need the linux binary of jdk14.
pkg_delete linux-sun-jdk-1.4.2.10
You can also "kldunload linux" and "kldunload linprocfs", unless of course you're running other apps under linux binary compatibility. Lastly, if you will not be using linprocfs,
umount /compat/linux/proc
Although redistributing JDK in binary form is forbidden under Sun's license agreement, for the sake of convenience we're going to create a binary package of our installed JDK. We could back this up and then use it to reinstall java on this same system should anything happen to it.
NOTE: we make absolutely no guarantees about the permissibility of doing this. We're not experts on Sun's licensing agreeement for java and even less so of Sun's interpretation of its own licensing agreement.
cd to the directory where you'd like your jdk14 binary to be placed, then:
pkg_create -b jdk-1.4.2p7_2
That should give you a nice little binary package of jdk14, which will be placed in the current directory, and which should have a filename of "jdk-1.4.2p7_2.tgz". (Obviously if you built your jdk14 using a more recent patchset than 7, the filename (and the command used to create the binary) will be slightly different, i.e. "jdk-1.4.2p8_2". Back it up for a rainy day if you so desire, but be aware that redistributing it violates Sun's license agreement.
That was a long, painful adventure, but we hope this has proved useful if you wanted to run jdk14 on FreeBSD.