Since Oracle had decided to keep their Java implementation to themselves, distributions have switched to integrating OpenJDK instead of the ex-SUN implementation. Unfortunately, there are companies out there that have not been able to implement their Java applications in a way that will work the same on OpenJDK as it worked on Oracle’s JRE, forcing especially corporate users to at least sometimes use Oracle’s version.
But since Oracle only provides a generic RPM, you’re on your own to integrate this properly into SuSE’s “update-alternatives” mechanism – which is what this article is about.
When you have openjdk installed, you actually need two separate packages to support both a generic JRE as well as a browser integration: “java-1_7_0-openjdk” (optionally accompanied by its devel companion) and “icedtea-web”. The first one creates the “java” group of alternatives, while the latter will add “javaplugin”.
In order to install Oracle’s Java implementation, your best bet is to download and install the RPM package corresponding to your system’s architecture, “Linux RPM” or “Linux x86 RPM”. This will i.e. get you “jre-1.7.0_51-fcs.x86_64” with its files installed in “/usr/java/jre1.7.0_51”. The post-install routines will add a symbolic link “/usr/java/latest/” pointing to the latest (Oracle) JRE install, too.
All you need to add now are the proper definitions to the “java” and “javaplugin” groups. You’ll have to do this manually, but if you refer to the “/usr/java/latest/” path (instead of the version-specific ones) you’ll not have to re-run these steps every of the numerous times you’ll be installing the latest Oracle Java security fixes. The following example is for 64bit Linux machines:
update-alternatives --install "/usr/bin/java" "java" "/usr/java/latest/bin/java" 1 \ --slave /usr/share/man/man1/java.1.gz java.1.gz /usr/java/latest/man/man1/java.1 \ --slave /usr/lib64/jvm/jre jre /usr/java/latest \ --slave /usr/bin/keytool keytool /usr/java/latest/bin/keytool \ --slave /usr/share/man/man1/keytool.1.gz keytool.1.gz /usr/java/latest/man/man1/keytool.1 \ --slave /usr/bin/orbd orbd /usr/java/latest/bin/orbd \ --slave /usr/share/man/man1/orbd.1.gz orbd.1.gz /usr/java/latest/man/man1/orbd.1 \ --slave /usr/bin/policytool policytool /usr/java/latest/bin/policytool \ --slave /usr/share/man/man1/policytool.1.gz policytool.1.gz /usr/java/latest/man/man1/policytool.1 \ --slave /usr/share/applications/policytool.desktop policytool.desktop /usr/java/latest/lib/desktop/applications/sun_java.desktop \ --slave /usr/bin/rmid rmid /usr/java/latest/bin/rmid \ --slave /usr/share/man/man1/rmid.1.gz rmid.1.gz /usr/java/latest/man/man1/rmid.1 \ --slave /usr/bin/rmiregistry rmiregistry /usr/java/latest/bin/rmiregistry \ --slave /usr/share/man/man1/rmiregistry.1.gz rmiregistry.1.gz /usr/java/latest/man/man1/rmiregistry.1 \ --slave /usr/bin/servertool servertool /usr/java/latest/bin/servertool \ --slave /usr/share/man/man1/servertool.1.gz servertool.1.gz /usr/java/latest/man/man1/servertool.1 \ --slave /usr/bin/tnameserv tnameserv /usr/java/latest/bin/tnameserv \ --slave /usr/share/man/man1/tnameserv.1.gz tnameserv.1.gz /usr/java/latest/man/man1/tnameserv.1 update-alternatives --install "/usr/lib64/browser-plugins/javaplugin.so" "javaplugin" "/usr/java/latest/lib/amd64/libnpjp2.so" 1 \ --slave /usr/bin/javaws javaws /usr/java/latest/bin/javaws \ --slave /usr/share/man/man1/javaws.1 javaws.1 /usr/java/latest/man/man1/javaws.1
You’ll have to substitute the directory names when doing this for 32bit systems:
update-alternatives --install "/usr/bin/java" "java" "/usr/java/latest/bin/java" 1 \ --slave /usr/share/man/man1/java.1.gz java.1.gz /usr/java/latest/man/man1/java.1 \ --slave /usr/lib/jvm/jre jre /usr/java/latest \ --slave /usr/bin/keytool keytool /usr/java/latest/bin/keytool \ --slave /usr/share/man/man1/keytool.1.gz keytool.1.gz /usr/java/latest/man/man1/keytool.1 \ --slave /usr/bin/orbd orbd /usr/java/latest/bin/orbd \ --slave /usr/share/man/man1/orbd.1.gz orbd.1.gz /usr/java/latest/man/man1/orbd.1 \ --slave /usr/bin/policytool policytool /usr/java/latest/bin/policytool \ --slave /usr/share/man/man1/policytool.1.gz policytool.1.gz /usr/java/latest/man/man1/policytool.1 \ --slave /usr/share/applications/policytool.desktop policytool.desktop /usr/java/latest/lib/desktop/applications/sun_java.desktop \ --slave /usr/bin/rmid rmid /usr/java/latest/bin/rmid \ --slave /usr/share/man/man1/rmid.1.gz rmid.1.gz /usr/java/latest/man/man1/rmid.1 \ --slave /usr/bin/rmiregistry rmiregistry /usr/java/latest/bin/rmiregistry \ --slave /usr/share/man/man1/rmiregistry.1.gz rmiregistry.1.gz /usr/java/latest/man/man1/rmiregistry.1 \ --slave /usr/bin/servertool servertool /usr/java/latest/bin/servertool \ --slave /usr/share/man/man1/servertool.1.gz servertool.1.gz /usr/java/latest/man/man1/servertool.1 \ --slave /usr/bin/tnameserv tnameserv /usr/java/latest/bin/tnameserv \ --slave /usr/share/man/man1/tnameserv.1.gz tnameserv.1.gz /usr/java/latest/man/man1/tnameserv.1 update-alternatives --install "/usr/lib/browser-plugins/javaplugin.so" "javaplugin" "/usr/java/latest/lib/i386/libnpjp2.so" 1 \ --slave /usr/bin/javaws javaws /usr/java/latest/bin/javaws \ --slave /usr/share/man/man1/javaws.1 javaws.1 /usr/java/latest/man/man1/javaws.1
Once you’ve run these commands, you’re set to switch between OpenJDK and Oracle’s Java:
usernode:~ # update-alternatives --config java There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib64/jvm/jre-1.7.0-openjdk/bin/java 17147 auto mode 1 /usr/java/latest/bin/java 1 manual mode 2 /usr/lib64/jvm/jre-1.7.0-openjdk/bin/java 17147 manual mode Press enter to keep the current choice[*], or type selection number: usernode:~ # update-alternatives --config javaplugin There are 2 choices for the alternative javaplugin (providing /usr/lib64/browser-plugins/javaplugin.so). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib64/IcedTeaPlugin.so 17106 auto mode 1 /usr/java/latest/lib/amd64/libnpjp2.so 1 manual mode 2 /usr/lib64/IcedTeaPlugin.so 17106 manual mode Press enter to keep the current choice[*], or type selection number: usernode:~ #
Two last words of advice: After switching “javaplugin”, you’ll have to restart all browser sessions so they will pick up the new plug-in… and don’t forget to check for updates of the Oracle Java implementation often, as it is known to need fixing quite regularly and security holes are quickly exploited!