Install Java 1.6 JRE and JDK On CentOS5

Very busy right now, so here’s a quick and dirty writeup for install Java 1.6 on centos5.

To install the JDK

yum install -y jpackage-utils
chmod +x jdk-6u14-linux-i586-rpm.bin

To install the JRE

If you dont have a build environment yet, create one (non-root user!) For example:

yum install -y rpm-build gcc gcc-c++ redhat-rpm-config
useradd builder
su - builder
vi ~/.rpmmacros

add the following:
%_topdir /home//rpmbuild
%_tmppath %{_topdir}/tmp
mkdir -p ~/rpmbuild/{SOURCES,SRPMS,SPECS,RPMS,tmp,BUILD}
cd ~/rpmbuild/SOURCES
Download Sun JDK 1.6 update 14 jdk-6u14-linux-i586.bin or jdk-6u14-linux-x64.bin

cd ~/rpmbuild/

Download the nosrc.rpm from jpackage
wget wget

Rebuild the packages:
rpmbuild --rebuild java-1.6.0-sun-

exit to root user

yum install jpackage-utils
Make sure you install the java and devel package, otherwise alternatives wont configure 1.6 properly
yum --nogpgcheck localinstall java-1.6.0-sun- java-1.6.0-sun-devel-

Select the new version of java to use:

alternatives --config java

Confirm that the correct version of java is running:

java --version

If its wrong, check the symlink for /usr/bin/java
Also check the $JAVA_HOME variable
Restart tomcat or whatever is using Java, to make sure its using the new JVM.

You can leave a response, or trackback from your own site.

Leave a Reply