**I made a slight edit to this to help when a newer version of java is released.**
I’m a Debian guy, used to be a Red Hat Guy.. and was a Fedora guy for a long time too.. In Ubuntu and Mint it’s very very easy to install Java, but in RHEL and CentOS this is apparently not the case, I looked into it for my good friend Dave Simon.
My Test Setup:
I started with a Clean install of CENTOS 5.5 on a Virtual Machine under Virtual Box, I didn’t enable SELINUX because his machine doesn’t face the Vile and Dangerous Interwebs, and I turned off the Firewall for the same reason.
I also edited the sudoers file to grant myself Sudo access (CentOS doesn’t do this by default, which i think is wise) and then updated the system with: sudo yum update, and 323 mb of packages later I had an up to date system running in a VM.
By Default I see that the OpenJdk is installed, this is not the same as Sun’s Java JRE and isn’t compatible with many programs but it does satisfy the license requirements of distros like CentOS. So.. on to the Oracle / Sun Java!
So.. Step One: Download the Java JDK.(you can probably do this with just the JRE, but the JDK covers all your bases and WHY go thru the pain more than once right??)
The Current file name you end up with will be named jdk-6u21-linux-i586.bin
Open a console as root (you can type ‘su root’ and put in your root pwd.)
chmod a+x jdk-6u21-linux-i586.bin
to make the file exectuable. Then you need to run the file.
./jdk-6u21-linux-i586.bin this will extract all the files to a folder named “jdk1.6.0_21” in the same directory.. you then (as root) need to rename and then move this directory.
mv jdk1.6.0_21 java
mv java /usr/
You now are ready to tell a program that CentOS has called “Alternatives” to use this Sun Java and not the Open Java.
in the same console window (as root of course) you will type
This gets you in the proper directory for alternatives, it’s not in a path so you have to be there to run these commands.
This is for the Java JRE
./alternatives --install /usr/bin/java java /usr/java/jre/bin/java 20000
This is for the Java Web Start
./alternatives --install /usr/bin/javaws javaws /usr/java/jre/bin/javaws 20000
This is for the Firefox Plugin for JRE
./alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jre/lib/i386/libnpjp2.so 20000
I think this is the Java C compliler (i dunno I don’t program in Java 😀 )
./alternatives --install /usr/bin/javac javac /usr/java/bin/javac 20000
You may now confirm your java version by typing
And in Firefox if you restat the browser you can check it’s plugins by first going to about:plugins in the address bar and then if you really wanna be sure head over to java.com and click the “Do I have java” link.
To Upgrade your Java:
You just need to download the latest JDK and then mv it into the /usr/java/ folder. Please try not to have any java processes running as it probably won’t be appreciated 😀
Categorised as: Geeking Out