Java/How To use Java with Firefox on 64-bit openSuSE 10.3

From openSUSE


Contents

Alternative approaches using packages from SUSE repositories

See end of this article.

Installing a standalone 32-bit version of Java and Firefox

Overview

x86_64 or 64-bit Linux, such as openSuSE 10.3, does not have a 64-bit Sun Java plugin for web browsers. Also, the i386, or 32-bit, plugin cannot be used with 64-bit web browsers such as Firefox.

Here is a work-around that, which keeps the 64-bit Firefox installation intact.

Traditionally, neither Java nor Firefox were installed 'sitewide' or as part of a distribution. Both Sun Java and Firefox come from a history of local, per-user installations. This can be used on a 64-bit system to create local, personal 32-bit Firefox, which will run the 32-bit Java plugin. Or alternatively, 32-bit Java and Firefox can be installed as standalone under /usr/local/, cleanly separated from the official directory tree and available to all users at the same time.

The cons are that only the 32-bit Firefox will use this 32-bit Java and that you have about 30mb of software installed just to visit freearcade.com. In addition, in the local installation, only you can use this version of Firefox, while the central installation requires root access. Another con is that these versions of Firefox and Java will not be patched by the automated YaST Online Update. You need to repeat the download and installation when a new version becomes available. Finally, add-ons installed on the 64-bit version are not recognized by the 32-bit version.

The pros are that you don't have to mess with update alternatives and package conflicts created by installing the RPMs of another version of Java that is incompatible with everything else on the system. You can copy the whole directories with Java and Firefox and know you have a working and complete Java on the web experience no matter what 64-bit Linux you use. Since bookmarks are stored in your ~/.mozilla directory, they are available to both versions of Firefox.

Decide if you prefer a local or central installation method and follow the corresponding instructions below.


Preparation

If you have openSUSE package 'java-1_6_0-sun-plugin' installed, uninstall it.

Install a 32-bit compatibility environment.

Download the tarball, not rpm, version of the Sun Java 32-bit Runtime (jre). Be sure to select the Linux (self-extracting file) version and Not the RPM version.

Download the Firefox distro for your language from Mozilla. The Linux downloads on this page are 32-bit tarballs, which is just what you need.

Installation

Local Installation in User Account

Creating a special sub-directory to hold all the files is useful. I create a bin directory in my $HOME as part of any new Linux account I am given. Since users eventually collect a lot of small tools, scripts or applets you may already have one.

mkdir ~/bin

Change to this directory.

cd ~/bin

and untar the files you downloaded earlier. This will create a firefox installation bellow the current directory.

tar -xvf /path/to/firefox-2.0.0.8.tar.gz

The java download is contained in a binfile which is just a shell script much like the old Loki installers or a self-extracting "sharchive." Run this bin file and accept the license to unpack the full java install.

sh /path/to/jre-6u3-linux-i586.bin

In my case, I now have

$HOME
 |
 +-/bin
   |
   +-/firefox
   |
   +-/jre1.6.0_03

Central Installation in /usr/local/

Another option is to install the downloaded 32bit standalone versions of Firefox and JRE under /usr/local, so it gets intalled only once and it can be accessed by any user in the system. There is no need to adapt any user settings, since /usr/local/bin is included in the user's $PATH by default.

While the local installation can be performed by any user, the central installation can only be done by root (or if user has sudo priviledges):

su -
cd /usr/local
tar xvf /path/to/firefox-2.0.0.8.tar.gz
sh /path/to/jre-6u3-linux-i586.bin


Post-install

Local Installation in User Account

If you start the ~/bin/firefox/firefox browser now, it won't know what Java to use. Install the plugin manually by linking it.

ln -s ~/bin/jre1.6.0_03/plugin/i386/ns7/libjavaplugin_oji.so \
    ~/bin/firefox/plugins/libjavaplugin_oji.so

Since this is locally installed, your environment still reflects the system-wide installation of Java. A script fixes that and a few common problems with the installation and execution:

vi ~/bin/firefox32

Which should contain:

#!/bin/bash
# Firefox32 with JRE for openSUSE 64b (by Waveclaw and CFLange)
# Note: Uninstall openSUSE package "java-1_6_0-sun-plugin", if installed.
# This software is provided without warranty.

# directory where standalone Firefox 32bit and JRE are installed
export PARENTDIR=$HOME/bin

#check if regular Firefox is running
if [ "`ps -ef |grep /usr/bin/firefox|grep -v grep`" != "" ]
   then
   echo "Please, close regular Firefox first."
   exit
fi

#customized java environment
export JAVA_HOME=$PARENTDIR/jre1.6.0_03
export JAVA_ROOT=$JAVA_HOME
export PLUGIN_HOME=$JAVA_HOME/plugin
export JAVA_BINDIR=$JAVA_HOME/bin

# good ol' classpath
export CLASSPATH=$JAVA_HOME/lib

#fix xlib locking issues
export LIBXCB_ALLOW_SLOPPY_LOCK=1

# add the 32-bit libs and the java, firefox binaries to my path
export LD_LIBRARY_PATH=$CLASSPATH:/lib:/usr/lib
export PATH=$PARENTDIR/firefox/:$JAVA_HOME/bin:$PATH

# run the 32-bit firefox web browser, now with Java!
$PARENTDIR/firefox/firefox $@

EOF

Make the script executable.

chmod +x ~/bin/firefox32

You are done.

Running ~/bin/firefox32 will start a web browser with Java support on your 64-bit Linux installation.

Central Installation in /usr/local/

As described above, the new installation of Firefox needs to be made aware of the 32-bit version of the Java plugin:

ln -s /usr/local/jre1.6.0_03/plugin/i386/ns7/libjavaplugin_oji.so \
    /usr/local/firefox/plugins/libjavaplugin_oji.so

Finally, to run the 32-bit Firefox with its own separate environment, avoiding conflict with the official 64-bit version and its plugins, create a new script in /usr/local/bin:

vi /usr/local/bin/firefox32
<pre>
Which should contain:
  1. !/bin/bash
  2. Firefox32 with JRE for openSUSE 64b (by Waveclaw and CFLange)
  3. Note: Uninstall openSUSE package "java-1_6_0-sun-plugin", if installed.
  4. This software is provided without warranty.
  1. directory where standalone Firefox 32bit and JRE are installed

export PARENTDIR=/usr/local

  1. check if regular Firefox is running

if [ "`ps -ef |grep /usr/bin/firefox|grep -v grep`" != "" ]

  then
  echo "Please, close regular Firefox first."
  exit

fi

  1. customized java environment

export JAVA_HOME=$PARENTDIR/jre1.6.0_03 export JAVA_ROOT=$JAVA_HOME export PLUGIN_HOME=$JAVA_HOME/plugin export JAVA_BINDIR=$JAVA_HOME/bin

  1. good ol' classpath

export CLASSPATH=$JAVA_HOME/lib

  1. fix xlib locking issues

export LIBXCB_ALLOW_SLOPPY_LOCK=1

  1. add the 32-bit libs and the java, firefox binaries to my path

export LD_LIBRARY_PATH=$CLASSPATH:/lib:/usr/lib export PATH=$PARENTDIR/firefox/:$JAVA_HOME/bin:$PATH

  1. run the 32-bit firefox web browser, now with Java!

$PARENTDIR/firefox/firefox $@

EOF </pre>

Make the script executable.

chmod a+x /usr/local/bin/firefox32

You are done.

Running firefox32 will start a web browser with Java support on your 64-bit Linux installation.

Notes

This is intended to get Java working in a web browser when you need it. No other support, such as using the 32-bit Firefox to play videos, is assumed or covered.

Close all instances of Firefox before switching between 64-bit and 32-bit versions. If you are running a 32-bit browser already and try to start a 64-bit Firefox browser, you will instead open another 32-bit browser window. When Firefox detects an existing running copy, it will open a new window with that copy instead of starting another web browser. The detection is not very smart - it fails to differentiate the two versions even if different profiles are used. For example, firefox32bit -P 32bit & followed by firefox64bit -P default & opens two 32-bit windows using the 32bit profile. The script above warns you about that, at least in the case of trying to run a 32-bit instance, when another 64-bit instance is already running.

Note that, if you have installed the openSUSE package 'java-1_6_0-sun-plugin', you have to uninstall it first.

Alternative approach

The Sun's Java

I was willing to use the 32bit version of Firefox as the primary browser. The following approach uses java 1.6.0 64bit for OpenOffice, etc., and java 1.5.0 32bit for the plugin. It works for me. (You'll need to make your own modifications, based on your original package selections).

Each of these bullets needs to be a separate iteration of the installer.

  • Remove 64bit (x86_64) Firefox.
  • Install the 32bit (i586) version.
  • Leave java-1_6_0_sun installed, but remove java-1_6_0-sun-plugin.
  • Remove 64bit java-1_5_0_sun and the corresponding plugin.
  • Install 32bit java-1_5_0_sun.
  • Install 32bit java-1_5_0_sun-plugin.

As always, YMMV.

The OpenJDK6 and IcedTea7

The ([Factory]) now contains the OpenJDK6 and a IcedTea7 (thanks to [Bernhard Kaindl]). It's a free software implementation of Java, based on Sun's OpenJDK (with some parts from GNU Classpath).

OpenJDK6 is much more mature and stable, as IcedTea, but was released later as IcedTea does. OpenJDK6 is Java6 and a IcedTea7 is a Java7 (not released and still in development).

Zypper (preffered and easiest way)

# add a Factory
zypper ar 
http://download.opensuse.org/distribution/SL-OSS-factory/inst-source/ 
Factory-OSS

# refresh it
zypper ref

# install a new rpm from Factory, to avoid ``bad magic'' error
zypper in -r Factory-OSS rpm

# install of openjdk
zypper in java-1_6_0-openjdk

# disable a Factory repo, because we want to have a 10.3, not a Factory :)
zypper mr -d Factory-OSS

# run - withouth -Xmx256m the jvm fails on a 
# ``Could not reserve enough space for object heap''
# error on my 10.3 system running in VirtualBox
java -Xmx256m -version
java version "1.6.0"
IcedTea Runtime Environment (build 1.6.0-b09)
OpenJDK Client VM (build 1.6.0-b09, mixed mode)

Same for IcedTea7 - the package name is java-1_7_0-icedtea.

Rpm way The other way is to use a BuildService's Web interface and click to the ymp to produce a OneClick install. But this leaves the Factory repository enabled in your system, which should be dangerous. The harder, but more secure way is to download and install rpms manually:

wget http://download.opensuse.org/distribution/SL-OSS-factory/inst-source/suse/x86_64/java-1_7_0-icedtea-1.5_b24-1.x86_64.rpm
wget http://download.opensuse.org/distribution/SL-OSS-factory/inst-source/suse/x86_64/java-1_7_0-icedtea-plugin-1.5_b24-1.x86_64.rpm
rpm -ivh java-1_7_0-icedtea-*
# to check
readlink /usr/lib64/browser-plugins/libjavaplugin.so
/etc/alternatives/libjavaplugin.so.x86_64
readlink /etc/alternatives/libjavaplugin.so.x86_64
/usr/lib64/jvm/jre-1.7.0-icedtea/lib/amd64/gcjwebplugin.so

Note: Using factory from 10.3 will not work due to rpmlib(PayloadIsLzma) <= 4.4.2-1 is needed by ... - see PayloadIsLzma. An update of rpm solves this problem - but will it create others, time will tell...

 wget http://download.opensuse.org/distribution/SL-OSS-factory/inst-source/suse/x86_64/rpm-4.4.2-199.x86_64.rpm
 rpm -Uvh rpm-4.4.2-199.x86_64.rpm

Postinstall check

Restart Firefox and type about:plugins. You should see a string GCJ Web Browser Plugin (using IcedTea) 1.2 (for icedtea7 GCJ Web Browser Plugin (using IcedTea) 1.5). Then you can try one of the Demo Applets to test it.

If you got a problem (eg. application crash), please follow instruction in howto [Bugs:An_application_crashed] and type into the Bugzilla.

If you'd like to use another Java plugin, you should read a Java/setDefaultJava#The_Java_plugin