Install Oracle Java 8 / 9 in Ubuntu 16.04, 18.04 Linux Mint 18

In this tutorial, we will learn how to install and configure Java 8 and 9 on ubuntu 18.04, 16.04 and Linux mint. We will use PPA to install the latest java.

This PPA repository is maintained by Webupb8 Team, That will automatically download the Java latest version from oracle official website and set up everything for you.

The following are the steps to install and configure the latest Java in your system.

1. Add the PPA

To add the PPA repository open your terminal and paste the following command.

sudo add-apt-repository ppa:webupd8team/java

Enter your password if it asks as we are using the Sudo command to add the PPA. Once you are done with adding the PPA.

Enter the following command to update your local system package index.

sudo apt-get update

2. Install Java

Once you update your repository enter the following command to install Java

sudo apt install oracle-java8-installer

While installing Java you will be prompted to accept the java license before it starts to download and install Java binaries.

Java Licence 

3. Check Java version

Once the installation is successful you will want to check the Java current installation version. Run the following command

javac -version

4. Set Java environment variables

The PPA we added also contains a package to automatically set the Java environment. To do so enter the following command

sudo apt install oracle-java8-set-default