How to Install Oracle Java on Ubuntu using PPA

Java programming technology, developed initially by Sun Microsystems has two variants now, one is supported by the Oracle company and another is supported by the Open Source community known as OpenJDK. In this post we will discover “How to Install Oracle Java on Ubuntu using PPA”. I have explained in my previous post “Procedure to Install Oracle Java on Ubuntu or Debian” by manual procedure, which also explains the differences between different variants of Java Run Time (called JRE) and Development Kits (called JDK).

READ: How To Install Oracle Java on Ubuntu or Debian

This tutorial will talk about How to Install Oracle Java on Ubuntu 14.04 LTS using PPA. We will PPA provided by, which is defacto standard for Ubuntu and many other platforms. This PPA supports Ubuntu 16.10, 16.04, 15.10, 14.04 and 12.04.

Now first thing we need to do is install java PPA to Ubuntu package repositories. To do so, use following comands –

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

Once source package repository is updated, install java package, by using command below –

sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java7-installer

Quick Hack: If you’re behind a firewall / router that blocks some of the redirects required to download the Oracle Java archive, you can download the JDK tar.gz archive manually and place it under /var/cache/oracle-jdk8-installer or /var/cache/oracle-jdk7-installer – then, installing the “oracle-java8-installer” or “oracle-java7-installer” package will use the local archive instead of trying it to download it itself.

Verify your installation

Once installed, you can use “java -version” in a terminal to verify your installation –

# java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
# javac -version
javac 1.8.0_102

Alternatively you can also use these commands –

# update-alternatives --display java
java - auto mode
 link currently points to /opt/jdk/jdk1.8.0_102/bin/java
/opt/jdk/jdk1.8.0_102/bin/java - priority 2001

# update-alternatives --display javac
javac - auto mode
 link currently points to /opt/jdk/jdk1.8.0_102/bin/javac
/opt/jdk/jdk1.8.0_102/bin/javac - priority 2001
Current 'best' version is '/opt/jdk/jdk1.8.0_102/bin/javac'.

Switching between Oracle Java 8 and Java 7

If you have multiple installation in parallel, that of Java 7 and Java 8, you can switch between the two using following commands –

sudo update-java-alternatives -s java-7-oracle
sudo update-java-alternatives -s java-8-oracle

Setting Java environment variables

You can use following commands to set default Environment variable. Please note that it will update the variables for both JRE and JDK.

sudo apt-get install oracle-java8-set-default
sudo apt-get install oracle-java7-set-default

So this concludes our tutorial on Automatically Installing Oracle Java on Ubuntu using PPA. If you encounter any problem after following above steps, please feel free to post a comment below.

One thought on “How to Install Oracle Java on Ubuntu using PPA

Leave a Reply

Your email address will not be published. Required fields are marked *

mautic is open source marketing automation