05 – Oracle JDK: Installation and version management

05 – Oracle JDK: Installation and version management

This time I show you two different ways to install and management Java in Ubuntu: manually and using PPA repository. The manual part of this tutorial also works fine for any linux. It’s recomended for professional installations.

Installing Oracle JDK/JRE using PPA (Recommended for my tutorials)

Open terminal and add webupd8team PPA repository:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Find proper JDK:

apt-cache search oracle-java
#or
#apt-cache search oracle-
oracle-jdk7-installer - Oracle JDK7 Installer meta package
oracle-java7-installer - Oracle Java(TM) Development Kit (JDK) 7
oracle-java6-installer - Oracle Java(TM) Development Kit (JDK) 6
oracle-java8-installer - Oracle Java(TM) Development Kit (JDK) 8
oracle-java7-set-default - Set Oracle JDK 7 as default Java
oracle-java6-set-default - Set Oracle JDK 6 as default Java
oracle-java8-set-default - Set Oracle JDK 8 as default Java
oracle-java7-unlimited-jce-policy - Unlimited JCE Policy for Oracle Java 7
oracle-java8-unlimited-jce-policy - Unlimited JCE Policy for Oracle Java 8
oracle-java9-installer - Oracle Java(TM) Development Kit (JDK) 9
oracle-java9-set-default - Set Oracle JDK 9 as default Java
oracle-java9-unlimited-jce-policy - Unlimited JCE Policy for Oracle Java 9

Install chosen version:

sudo apt-get install <package_name>
#ie JDK 1.7
sudo apt-get install oracle-java7-installer

Default JDK directory

The default webupd8team Oracle JRE/JDK installation directory is:

/usr/lib/jvm/

 

Switching between Java versions

If you install more than one oracle-java<version>-installer, you can switch between them using one of:

#oracle-java7-set-default - Set Oracle JDK 7 as default Java
#oracle-java6-set-default - Set Oracle JDK 6 as default Java
#oracle-java8-set-default - Set Oracle JDK 8 as default Java
sudo apt-get install oracle-java7-set-default

Oracle JDK/JRE manual installation (Recommended for professionals)

Download proper JDK/JRE version from Oracle Downloads (tar.gz version) and unzip archive to ~/Tools directory.

Oracle asks you to accept licence. To download JDK with accept licence automatically just use wget with additional header:

mkdir Tools
cd Tools
#Downloading
#wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" <java_dovnload_link>
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz

#Unzipping
#tar -xvf <package_name>.gz
tar -xvf jdk-8u91-linux-i586.tar.gz 

Setting default java

Create symbolic link to selected java version:

sudo ln -s <HOME_PATH>/Tools/jdk1.8.0_91/bin/java /usr/bin/java

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu