Install Oracle Java 8 with PPA on Ubuntu 16.04

This post provides the instructions to install Oracle JDK 8 on Ubuntu 16.04. (Notes: Do not install JDK 9 yet, JDK 8 is the latest most stable version.)

(If you are not sure which JDK — OpenJDK or Oracle JDK — to install, check this post for the main difference between them.)

The PPA of Oracle Java for Ubuntu is being maintained by Webupd8 Team. JAVA 8 is released with many of new features and security updates, read more about whats new in Oracle Java 8.

  • Add Oracle’s PPA, then update your package repository.

We need to add webupd8team Java PPA repository onto our system. Then install Oracle Java 8 by issuing the following commands.

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

Note that when issuing the command:
sudo add-apt-repository ppa:webupd8team/java
if you get the error:
sudo: add-apt-repository: command not found
do the following:
sudo apt-get install software-properties-common
And then rerun adding your repository.

Note that it is possible to install multiple Java installations on one machine, and set one of installed versions as the default. Check out How To Install Java with Apt-Get on Ubuntu 16.04 (April 23, 2016)  (pdf), in particular the “Managing Java” section.

  • Verify Installed Java Version

After successfully installing Oracle Java, use the following to verify what version we installed.

$ java -version 

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
  • Configuring Java Environment and Set the JAVA_HOME Environment Variable

We also need to install java configuration package. The package should come with the latest operating systems during installation of JAVA packages. But it does no harm to run the following command to be sure we have it installed on our machine.

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

Many programs use the JAVA_HOME environment variable to determine the Java installation location.

Copy the path from your preferred installation and then open /etc/environment configuration file using  nano or your favorite text editor, to set JAVA_HOME environment variable.

sudo nano /etc/environment

At the end of this file, add the following line, making sure to replace the highlighted path with your own copied path.


Save and close the file and exit nano editor environment. (Note: Ctrl+O to save the file, and then hit Enter, and then Ctrl +X to close and exit the file.)

Use the following command to reload the file.

  • source /etc/environment

You can now test whether the environment variable has been set by issuing the following command:


This will return the path you just set.

  • Conclusion

We have now installed Java 8 on our system and set it as default. We can now install software which runs on Java, such as Tomcat and Solr.



How To Install Java with Apt-Get on Ubuntu 16.04 (April 23, 2016)  (pdf)

This is a very good post, it introduced the installation of both OpenJDK and Oracle JDK 6/7/8/9

How to Install Oracle JAVA 8 (JDK/JRE 8u121) on Ubuntu & LinuxMint with PPA (Mar 29, 2017 by Rahul K.)  – pdf


1 thought on “Install Oracle Java 8 with PPA on Ubuntu 16.04”

Leave a Reply

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