This HOWTO provides detailed instructions for switching from the default GJC runtime to the Sun Java JRE.
RedHat by default comes with GNU Java tools (GJC).
- RHEL4-5.1: The IBM JDK or the BEA JDK are in the "extra" channel. But what if you want to use the Sun JDK... Current licensing (2007/05) doesn't allow Sun JDK to be distributed by RedHat. (Maybe this will change with openJava?) Fortunately RedHat is actively involved with JPackage which makes it fully JPackage compatible! (hooray!)
If you use this guide, then the entire system will end up using the Sun JDK. So also a Tomcat that is installed with RH packages will use it (after a restart).
Installation of the Sun JDK is also explained at http://www.jpackage.org/installation.php - RHEL5.2(+?): You'll find the RHEL Sun Java packages in the 'supplementary' channel. (see the relevant section in this document)
check the current java(c) version:
$ java -version
[probably the GNU one]
$ javac -version
[probably the Eclipse Java Compiler]
Install the Sun JDK (pre RHEL5.2 instructions)
- get the latest Sun JDK RPM:
Go to the directory where you want to download, extract and install (eg: cd /tmp, cd /root).Choose the link to the latest JDK.$ links http://java.sun.com/javase/downloads/index.jsp
On the download page: accept the agreement in links and download the JDK RPM-in-bin for linux. - Make the downloaded binary executable and run it:
The rpm is extracted from the bin and installed (accept the license).
$ chmod u+x jdk-<version>-linux-i586-rpm.bin $ ./jdk-<version>-linux-i586-rpm.bin
The java version is now installed in /usr/java/. This dir contains all individual versions and two symlinks: "latest" and "default". You should never reference to any of these locations (see 4). - Get the matching JPackage compatibility package for this Sun JDK:
$ links ftp://jpackage.hmdc.harvard.edu/JPackage/1.7/generic/RPMS.non-free/ $ rpm -ivh java-x.x.x-sun-compat-x.x.x.xx-1jpp.i586.rpm
Install the Sun JDK (RHEL5.2 or higher instructions)
- Subscribe your system to the 'supplementary' channel in Red Hat Network.
- Install the latest packages from the repository:
$ yum install java-1.6.0-sun-devel
Make the Sun VM default for the system
To make the Sun JDK the default for the entire system, use the 'alternatives' method. This will create symlinks in /etc/alternatives/ that are used throughout the entire system (eg see "$ ll /usr/bin/java").
[select the Sun version instead of the GNU version for each of these commands]
$ /usr/sbin/alternatives --config java $ /usr/sbin/alternatives --config javac
check the new installation
$ java -version
[should be the new Sun version]
$ javac -version
[should be the new Sun version]
Tomcat restart (optional)
Make Tomcat use this JDK now by restarting it:
$ /etc/init.d/tomcat5 restart