install and setup JAVA JDK in CentOS 6
1. The first thing I've done was to make sure the CentOS 6 system is fully up-to-date, so I ran
yum update
2. Once the update completed, I then checked the system for any other installed
JAVA
packages usingthere was therpm -qa | grep -E '^open[jre|jdk]|j[re|dk]'
java-1.6.0-openjdk-1.6.0.0-1.56.1.11.8.el6_3.i686
package already installed so I removed it by runningyum remove java-1.6.0-openjdk
3. The next step was to go and download the required
Note that I needed to install an older version of JAVA JDK since it was specific to the software I was setting up.JAVA JDK
package for the system I was working on. It was a 32 bit CentOS 6 so I
needed to get the 32 bit JAVA JDK package from Oracle's JAVA download
pageDownload JAVA JDK6 here
Download JAVA JDK7 here
You may also
wget
Oracle JDK 7
using command line as inJAVA JDK 7
for 64bit (x86_64) system
for 32bit (x86) systemwget --no-cookies \ --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \ "http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.rpm" \ -O /opt/jdk-7u45-linux-x64.rpm --no-check-certificate
JAVA JDK 6wget --no-cookies \ --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \ "http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-i586.rpm" \ -O /opt/jdk-7u45-linux-i586.rpm --no-check-certificate
for 64bit (x86_64) system
for 32bit (x86) systemwget --no-cookies \ --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \ "http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-x64-rpm.bin" \ -O /opt/jdk-6u45-linux-x64-rpm.bin --no-check-certificate
wget --no-cookies \ --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \ "http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-i586-rpm.bin" \ -O /opt/jdk-6u45-linux-i586-rpm.bin --no-check-certificate
4. Once the
a) Installing the JAVA JDK6 package in CentOS 6JAVA JDK
package got downloaded I proceeded with installing the package.b) Installing the JAVA JDK7 package in CentOS 6chmod +x /opt/jdk-6u45-linux-i586-rpm.bin /opt/./jdk-6u45-linux-i586-rpm.bin
rpm -Uvh /opt/jdk-7u45-linux-i586.rpm
5. Once the
a) Setting up the JAVA JDK
package is installed, I then needed to configure it on the system using the alternatives
command. This is in order to tell the system what are the default
commands for JAVA. Most sys admins aren't aware about this and I think
that it is a vital part when setting the JAVA packageJAVA JDK6
packagethis set the default commands foralternatives --install /usr/bin/java java /usr/java/jdk1.6.0_45/jre/bin/java 20000 alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_45/bin/jar 20000 alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_45/bin/javac 20000 alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.6.0_45/jre/bin/javaws 20000 alternatives --set java /usr/java/jdk1.6.0_45/jre/bin/java alternatives --set javaws /usr/java/jdk1.6.0_45/jre/bin/javaws alternatives --set javac /usr/java/jdk1.6.0_45/bin/javac alternatives --set jar /usr/java/jdk1.6.0_45/bin/jar
JAVA JDK7
and listing the /etc/alternatives/
directory showed the followingb) Setting up thels -lA /etc/alternatives/ lrwxrwxrwx. 1 root root 29 Feb 22 03:39 jar -> /usr/java/jdk1.6.0_45/bin/jar lrwxrwxrwx. 1 root root 34 Feb 22 03:39 java -> /usr/java/jdk1.6.0_45/jre/bin/java lrwxrwxrwx. 1 root root 31 Feb 22 03:39 javac -> /usr/java/jdk1.6.0_45/bin/javac lrwxrwxrwx. 1 root root 36 Feb 22 03:39 javaws -> /usr/java/jdk1.6.0_45/jre/bin/javaws
JAVA JDK7
packagethis set the default commands foralternatives --install /usr/bin/java java /usr/java/jdk1.7.0_45/jre/bin/java 20000 alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_45/bin/jar 20000 alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_45/bin/javac 20000 alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_45/jre/bin/javaws 20000 alternatives --set java /usr/java/jdk1.7.0_45/jre/bin/java alternatives --set javaws /usr/java/jdk1.7.0_45/jre/bin/javaws alternatives --set javac /usr/java/jdk1.7.0_45/bin/javac alternatives --set jar /usr/java/jdk1.7.0_45/bin/jar
JAVA JDK7
and listing the /etc/alternatives/
directory showed the followingls -lA /etc/alternatives/ lrwxrwxrwx. 1 root root 29 Feb 22 03:39 jar -> /usr/java/jdk1.7.0_45/bin/jar lrwxrwxrwx. 1 root root 34 Feb 22 03:39 java -> /usr/java/jdk1.7.0_45/jre/bin/java lrwxrwxrwx. 1 root root 31 Feb 22 03:39 javac -> /usr/java/jdk1.7.0_45/bin/javac lrwxrwxrwx. 1 root root 36 Feb 22 03:39 javaws -> /usr/java/jdk1.7.0_45/jre/bin/javaws
6. Finally I verified the installed version of JAVA
java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)
I know this how-to will serve me as a quick reference for installing Oracle JAVA in the future and I truly hope this will help someone else too.source
Comments
Post a Comment