Starting from Fedora Core 4, users are recommended to not use the Java RPM provided by Sun. The relevant section of the release notes state:
Fedora Core 4 users are advised
not to use the Java RPM provided by
Sun. It contains Provides that conflict with names used in packages
provided as part of Fedora Core 4. Because of this, Sun Java might
disappear from an installed system during package upgrade operations.
Fedora Core 4 users should use either the RPM from jpackage.org or
manually install the Sun Java tarball into /opt. Sun Java 1.5+ is
recommended for stability purposes.
This is also true for F7, as the same issues still affect it. As a result, we will be installing java into /opt. Be sure that SELinux has been configured properly before starting (see the SELinux page).
Installing Java
Open your favorite web browser and go to Sun's download page for Java SE, which is located at:
Scroll down the page and look for the latest update to the "Java Runtime Environment (JRE) 6 Update 2". Click on the Download button, click the radio button to accept the license agreement, and choose the "Linux self-extracting file" link, which corresponds to jre-6u1-linux-i586.bin. After it downloads, copy the file to /opt:
~>
sudo cp ~/Download/jre-*.bin /opt/.
Now change into the /opt
directory: ~>
cd /opt
And change the permissions of
the file so that it is executable: ~>
sudo chmod ugo+x jre-*.bin
Next, run the binary file
using sudo: ~>
sudo ./jre-*.bin
Continue to press the space
bar until you scroll down to the end of the license agreement. Type "yes" and hit Enter. Wait
for the installation to complete, and delete the binary file: ~>
sudo rm jre-*.bin
Configuring the Java pluginTo configure the Java plugin, simply create the appropriate soft link to /usr/lib/mozilla/plugins:
~>
sudo ln -s /opt/jre1.6.0_02/plugin/i386/ns7/libjavaplugin_oji.so
/usr/lib/mozilla/plugins/.
Restart Firefox to enable the
Java plugin. To test it, go to
http://www.java.com/en/download/help/testvm.xml.Configuring Java for Other Applications
To configure java for additional applications, we need to create a couple of profile files in /etc/profile.d. For the bash shell, create a file /etc/profile.d/java.sh with the following information:
export
J2RE_HOME=/opt/jre1.6.0_02
export PATH=$J2RE_HOME/bin:$PATH
Next, create a
file /etc/profile.d/java.csh
for csh/tcsh shells:export PATH=$J2RE_HOME/bin:$PATH
set
J2RE_HOME=/opt/jre1.6.0_02
set path=($J2RE_HOME/bin $path)
If you are using bash as your
default shell, source the java.sh
file:set path=($J2RE_HOME/bin $path)
$
source /etc/profile.d/java.sh
If you are using csh/tcsh as your
default shell, as I am, source the java.csh file
instead: ~>
source /etc/profile.d/java.csh
To verify that we
will use the newly
installed java
application, type: ~>
which java
You should see: /opt/jre1.6.0_02/bin/java
Next we will use
the alternatives
command to further configure F7 to use jre1.6.0.
Type: ~>
sudo /usr/sbin/alternatives --install /usr/bin/java java
/opt/jre1.6.0_02/bin/java 2
This configures jre1.6.0_01
as an alternative to the generic java
implementation that comes bundled with F7. To choose it, type: ~>
sudo /usr/sbin/alternatives --config java
in which case,
you should see: There
are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
+ 2 /opt/jre1.6.0_02/bin/java
Enter to keep the current selection[+], or type selection number:
Press '2' and hit Enter.
Finally, type:Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
+ 2 /opt/jre1.6.0_02/bin/java
Enter to keep the current selection[+], or type selection number:
~>
sudo /usr/sbin/alternatives --display java
You should see
that the link currently
points to /opt/jre1.6.0_02/bin/java: java
- status is manual.
link currently points to /opt/jre1.6.0_02/bin/java
/usr/lib/jvm/jre-1.5.0-gcj/bin/java - priority 1500
slave keytool: /usr/lib/jvm/jre-1.5.0-gcj/bin/keytool
slave rmiregistry: /usr/lib/jvm/jre-1.5.0-gcj/bin/rmiregistry
slave jre_exports: /usr/lib/jvm-exports/jre-1.5.0-gcj
slave jre: /usr/lib/jvm/jre-1.5.0-gcj
/opt/jre1.6.0_02/bin/java - priority 2
slave keytool: (null)
slave rmiregistry: (null)
slave jre_exports: (null)
slave jre: (null)
Current `best' version is /usr/lib/jvm/jre-1.5.0-gcj/bin/java.
You are now able
to install and run Java
applications!link currently points to /opt/jre1.6.0_02/bin/java
/usr/lib/jvm/jre-1.5.0-gcj/bin/java - priority 1500
slave keytool: /usr/lib/jvm/jre-1.5.0-gcj/bin/keytool
slave rmiregistry: /usr/lib/jvm/jre-1.5.0-gcj/bin/rmiregistry
slave jre_exports: /usr/lib/jvm-exports/jre-1.5.0-gcj
slave jre: /usr/lib/jvm/jre-1.5.0-gcj
/opt/jre1.6.0_02/bin/java - priority 2
slave keytool: (null)
slave rmiregistry: (null)
slave jre_exports: (null)
slave jre: (null)
Current `best' version is /usr/lib/jvm/jre-1.5.0-gcj/bin/java.


