Installing Oracle JDK / JRE in CentOS Ubuntu


In earlier days (while SUN), Installing JRE / JDK in a VM is very easy process just like extracting a file and use it. Now wget-ing the source file itself a bit long process. After that you have use few commands to set this newly installed Java as default Java. So I have came up with list of steps to make installing java easier in CentOS and Ubuntu.

Downloading JDK...?

In VM's usually you get terminal not GUI. So I followed command way in this tutorial. You have to add cookies to download java via wget command.

For CentOS

wget --no-cookies --no-check-certificate \
--header ";oraclelicense=accept-securebackup-cookie" \

For Ubuntu

wget --no-cookies --no-check-certificate \
--header ";oraclelicense=accept-securebackup-cookie" \

I wrote a python script to download the Oracle Java jdk / jre from terminal.

That script in

How to Use

wget --no-check-certificate
chmod +x

It will ask for the type of package you want to download and version of package want to download. Finally the selected file will be downloaded in the current directory

Installing and Setting...?

In the installation to make this java as default one in the system wide.

For CentOS

rpm -Uvh jdk-7u55-linux-x64.rpm
alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 2
alternatives --install /usr/bin/java java /usr/java/latest/bin/java 2
alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 2

For Ubuntu

sudo mkdir -p /usr/java/jdk1.7.0_55
sudo tar -xzvf jdk-7u55-linux-x64.tar.gz -C /usr/java/
sudo ln -s /usr/java/jdk1.7.0_55/usr/java/latest
sudo ln -s /usr/java/latest /usr/java/default
sudo update-alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 2
sudo update-alternatives --install /usr/bin/java java /usr/java/latest/bin/java 2
sudo update-alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 2

For ubuntu there is a PPA released by webupd8team.

PPA way

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Note: But that is not working since 16th March. Hope they fixed now.

Show Comments