Tuesday, August 26, 2014

Install Oracle Sun Java to CentOS

Install Oracle Sun Java to CentOS

Download Oracle Java 7 JDK for Linux:
I prefer RPM. The tar.gz is an alternative available mainly for non-root users.

Note for x86 and x64
You can choose between x86 and x64 versions. You cannot install both together from RPM package. You can install one from RPM and the second manually from tar.gz.

Download (accept licence):

Download (shell command)
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.rpm

Install java from rpm:
rpm -i *.rpm

Upgrade Java (optional):
rpm -Uvh jdk-7u-linux-x64.rpm

Setup Java
## java
alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 200000

## javaws
alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 200000

## Install javac only if you installed JDK (Java Development Kit) package
alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 200000
alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 200000

Choose Oracle Java as default
alternatives --config java
alternatives --config javaws
alternatives --config javac

Setup path
Add to /etc/profile file or ~/.bash_profile or to ~/.bashrc
export JAVA_HOME="/usr/java/latest"
Java JDK and JRE absolute version (/usr/java/jdk1.7.0_67)

Check version
java -version
javac -version


Oracle Java install doc:

All steps in detail at:

Auto accept licence:


No comments: