Update: We’ve written a new guide for installing JRE 6. Please visit “Update on installing JRE 6 on CentOS“!
On our task to install the latest Java on our CentOS 5 machine we encountered that simply running the RPM from Sun’s Website is not enough. Here are the steps that we did to get Java installed properly.
- Get the latest JRE from SUN and download the RPM.
- Once done issue “chmod a+x” on the RPM.
- Then simply use “./jrexxxx” (the filename of the RPM) and let it run. This will install the JRE in /usr/java/jre1.6.0_04/bin/java.
You now expect that the latest JRE is installed, right? Alas, it is not so. You are still getting the default Java installation:
# java -version
java version “1.4.2_06″
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
Looking around a bit we found that the path “/usr/bin/java” is a symbolic link pointing to the default Java location. So all you have to do now is to remove the existing symbolic link and create a new one to our JRE 1.6.0 installation. This is done with:
ln -s /usr/java/jre1.6.0_04/bin/java /usr/bin/java
When you now check on the version you should get the new Java version.
# java -version
java version “1.6.0_04″
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
If you enjoyed this post, make sure you subscribe to the RSS feed!
Following your instructions I successfully get the jre loaded. However, when I do a “alternatives –config java” the new jre isn’t listed (see below).
I’m a new linux admin/user and trying to configure Centos 5 to run Alfresco.
Thanks . . .
***reference below***
There is 1 program that provides ‘java’.
Selection Command
———————————————–
*+ 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
Hi Ken
I don’t see what the command “alternatives –config java” would bring you.
Please see where “ls -l /usr/bin/java” is pointing to. Also if you see the new JRE under “ls -l /usr/bin/”, or not.
You should really check out the official CentOS wiki page for installing a JDK. By not using the JPackage utility and simply using a symlink you are not addressing the java compiler or any shared libraries. While this might not be a problem if you’re simply running the occasional java program or applet, it can be disastrous for anyone developing Java on the system or running an application server.
Another huge benefit of using JPackage and the Alternatives utility is that you can actually install multiple JDKs on a single system and switch between them. This can be very useful in a development environment where a developer needs to run JDK 1.5 for a legacy application and still have 1.6 at their disposal for new application development.
http://wiki.centos.org/HowTos/JavaOnCentOS
http://jpackage.org
Thank you for the tip with the Wiki. I did not know that one.
Before we posted this we have installed the jpackage but somehow it did not work as expected. The only way we could get it running was with the above method.
We do run application servers on this machine and have not seen any problems with it. We even installed a lot of Oracle software on it (which runs the installer in Java and alike) and have not seen any problems.
[...] 06.26.08 (3 seconds ago) | No Comments Looking at my blog statistics shows that my post on “Installing the latest JRE 6 on CentOS” is one of the top positions. Also a lot of search engines referrals come to this [...]