Friday, 1 October 2010

Adding Java to Mozilla Firefox 3.6.9 on Red Hat Enterprise Linux 5.5

Having helped a friend get this working earlier, I thought I'd document it pour la encourager les autres.

Download the latest Java 6 JRE as an RPM from: -

http://javadl.sun.com/webapps/download/AutoDL?BundleId=40906

This comes down as a 20 MB .BIN file: -

[root@wpx7 ~]# ls -al jre-6u21-linux-i586-rpm.bin

-rw-r--r-- 1 root root 20694516 Oct  1 16:01 jre-6u21-linux-i586-rpm.bin

which needs to be set as executable - I choose to do this using the chmod +x command: -

[root@wpx7 ~]# chmod +x /root/jre-6u21-linux-i586-rpm.bin

[root@wpx7 ~]# ls -al jre-6u21-linux-i586-rpm.bin

-rwxr-xr-x 1 root root 20694516 Oct  1 16:01 jre-6u21-linux-i586-rpm.bin

Once this is done, the .BIN file can be executed to carry out the RPM installation: -

[root@wpx7 ~]# /root/jre-6u21-linux-i586-rpm.bin

Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
  inflating: jre-6u21-linux-i586.rpm 
Preparing...                ########################################### [100%]
   1:jre                    ########################################### [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        localedata.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...

Done.

Having done this, I need to identify the current JRE in use: -

[root@wpx7 ~]# which java
/usr/bin/java

[root@wpx7 ~]# ls -al /usr/bin/java

lrwxrwxrwx 1 root root 22 Jul  2 06:44 /usr/bin/java -> /etc/alternatives/java

and then replace it with the newly downloaded/installed Java: -

[root@wpx7 ~]# rm /usr/bin/java
rm: remove symbolic link `/usr/bin/java'? y

[root@wpx7 ~]# ln -s /usr/java/latest/bin/java /usr/bin/

Having done this, the command which java still returns: -

/usr/bin/java

but we have a different version: -

[root@wpx7 ~]# java -version

java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)

The final trick is to add the new JRE's plugin to Firefox.

Now this has changed over the years, so it took me a while to find it - in the current Firefox 3.6 world, the easiest way is to create a link to the plugin in a directory underneath the user's home directory.

First we locate the plugin: -

[root@wpx7 ~]# locate libnpjp2

/opt/IBM/WebSphere/AppServer/java/jre/lib/i386/libnpjp2.so
/opt/IBM/WebSphere/AppServer/updateinstaller/java/lib/i386/libnpjp2.so
/usr/java/jre1.6.0_21/lib/i386/libnpjp2.so

As you can see, I already have the WebSphere JRE, but I'm looking to use the Sun JRE within my browser, so I need the third copy of the plugin: -

[root@wpx7 ~]# ls -al /usr/java/jre1.6.0_21/lib/i386/libnpjp2.so

-rwxr-xr-x 1 root root 77510 Jun 22 09:47 /usr/java/jre1.6.0_21/lib/i386/libnpjp2.so

The plugin will need to go into a directory called: -

/root/.mozilla/plugins

( as root is my user )

Although the .mozilla directory exists under my home directory ( /root or ~ for short ), the plugins subdirectory does not.

[root@wpx7 ~]# mkdir /root/.mozilla/plugins

Well, it does now :-)

I now need to create a symbolic link ( aka short-cut ) from the plugin file ( libnpjp2.so ) into this new directory: -

[root@wpx7 ~]# ln -s /usr/java/jre1.6.0_21/lib/i386/libnpjp2.so /root/.mozilla/plugins/

Having done this, I can start Firefox, and type the URL/command: -

about:plugins

into the Address bar.

This, amongst other things, shows me: -

Java(TM) Plug-in 1.6.0_21

    File: libnpjp2.so
    Version:
    The next generation Java plug-in for Mozilla browsers.

MIME Type Description Suffixes Enabled
application/x-java-vm Java™ Plug-in Yes
application/x-java-applet Java™ Plug-in Applet Yes
application/x-java-applet;version=1.1 Java™ Plug-in Yes
application/x-java-applet;version=1.1.1 Java™ Plug-in Yes
application/x-java-applet;version=1.1.2 Java™ Plug-in Yes
....

Having done this, I can now test the newly installed and configured Java plugin, by opening a browser session to: -

http://www.java.com/en/download/help/testvm.xml

at which point I see an applet loading, and: -

Your Java is working
Java update available

Your Java configuration is as follows:

Vendor: Sun Microsystems Inc.
Version: Java 6 Update 21
Operating System: Linux 2.6.18-194.11.3.el5
Architecture: i386

which is nice :-)

No comments:

Reminder - installing podman and skopeo on Ubuntu 22.04

This follows on from: - Lest I forget - how to install pip on Ubuntu I had reason to install podman  and skopeo  on an Ubuntu box: - lsb_rel...