As you may have noticed, this web site has a couple of Java applets on it. I figured I should be able to access the applets via Mozilla on FreeBSD. The Java VM under Mozilla was working successfully on Linux, so I expected it to be an easy process.
On the basis of no research whatsoever, I decided to accept the Mozilla offer to download the Linux Java plugin when I tried to access one of the applets. My first problem was that it failed to install, due to access permissions. OK, I'll download it as root. That seemed to work OK, but using the 'About Plugins' menu revealed that no java plugin was recognised by Mozilla.
Mozilla was complaining that it could not find the shared library
libjavaplugin_oji.so
. Well, I had one of those in the
/usr/X11R6/lib/mozilla/plugins/java2
subdirectories, which
is where the plugin download had placed it. I read (somewhere) that
you could tell Mozilla about the plugin by creating a link under the
~/.mozilla/plugins
directory. Well, that changed things,
but not particularly for the better. Now Mozilla was complaining
that it couldn't find libgtk-1.2.so.0
.
I then started up the path of creating links, one by one, to the library modules that seemed to match what Mozilla was looking for:
libgdk-1.2.so.0
libgmodule-1.2.so.0
libglib-1.2.so.0
libstdc++-libc6.1-1.so.2
libm.so.6
At this point I realised the futility of what I was doing. I deleted all the links I had created, and started to research the problem properly. Naturally, I quickly found out what I had to do. The resolution is outlined at http://www.freebsd.org/java.
In short, java 1.3.1 needs to be installed, patched for FreeBSD,
which can only be performed via the ports system. The make process
will identify the downloads required, but rather than getting some
of the them automatically, it tells you to download them manually,
and place them in /usr/ports/distfiles
. Once make is
complete, issue the command make install
.
Once the java installation is complete, you must create a link from
/usr/X11R6/lib/mozilla-devel/plugins/libjavaplugin_oji.so
to
/usr/local/jdk1.3.1/jre/plugin/i386/ns600/libjavaplugin_oji.so
.
After all that, the applets were running successfully. The only problem is that the VM is a slow as a dog!
Much later, I used portupgrade
to bring all the ports
up-to-date, forgetting about the Java wrinkles. I didn't remember
until I tried to run an applet in Mozilla, and nothing happened. I
therefore started the process of installing the j2dsk-1.4.2
via ports.
Once again, this provides instructions on manually downloading the
various source packages, and placing them in
/usr/ports/distfiles
, but there is one difference. If you
fail to issue the following commands prior to performing the build,
it will fail.
kldload linprocfs mount -t linprocfs linprocfs /compat/linux/proc
The absence of linprocfs affects the Linux version of Java which is used to bootstrap the native FreeBSD version. You will find the Linux Java VM issues the following error message on startup:
Java HotSpot(TM) Client VM warning: Can't detect initial thread stack location
What's worse is that the file
usr/ports/java/jdk14/work/control/build/bsd-i586/gensrc/java/util/CurrencyData.java
contains this error message as its first line, causing the native JDK
build to fail.
If you do end up in this situation, recovery is possible. Delete
the errant error message in the CurrencyData.java
file, set
the linprocfs up as shown, and restart the make.
The final step, to support Java applets in Mozilla, is to create a link for libjavaplugin_oji.so. The locations are slightly different to those given above, since Mozilla is now at version 1.7.3.
ln -s /usr/local/jdk1.4.2/jre/plugin/i386/ns610/libjavaplugin_oji.so \ /usr/X11R6/lib/mozilla/plugins/libjavaplugin_oji.so
The VM speed has improved considerably.