Install Oracle Java 7/8 on Ubuntu

If you are a bit into computers you must be knowing that java is a must for several or I would say many important applications. By default JDK is not installed in your Linux distro (Ubuntu), so to utilize the functionality of your system to its full extent we have to install it separately.  

Oracle JAVA 8 is a stable release and available to download and install on the official download page.

Oracle Java PPA for Ubuntu is being maintained by Webupd8 Team and can be downloaded from there easily, which sets up everything for you on its own.

Here is a tutorial to install Oracle Java 7 and Oracle Java 8 on your distro.  


The webupd8 ppa no longer has Java installer. Most Linux distributions default ppa has Java installer available. Please use the following command to install java in your Ubuntu based Linux distro.

Install Java from default PPA

sudo apt install openjdk-11-jre
sudo apt install openjdk-11-jdk

To install a different java version, replace ’11’ with the version number.

Install Java from default PPA
Install Java from default PPA

How To Install Java On Ubuntu?


No longer works. Instead, try the above method.

Basically we will have to install the packages and then run the installer. Java will be installed easily.

Step 1: Add the PPA

We will have to download the required files(PPA) to the system. To add the PPA open the terminal(Ctrl+Alt+T) and run the following command :

This requires admin rights so we will have to use sudo.

For Oracle Java 7/8:

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

To enter the password after running this command and press Enter.

install java in ubuntu 16.04

Press Enter again to allow it to add.

Step 2: Next we have to update the packages.

As now we have downloaded the files, we have to update.

Use the command :

sudo apt update

Step 3:Final step is to run the installer. This installer installs the java in your system.

On running it asks for some permissions which you will have to grant.

Run the following command :

For Oracle Java 7: sudo apt-get install oracle-java7-installer

For Oracle Java 8: sudo apt-get install oracle-java8-installer

install oracle java 8 in ubuntu

Next, the screen will appear for license agreement, so press OK.

configure java8 in ubuntu

Next the screen will appear asking for whether to install or not. Choose YES and press Enter.

Now the Java is installed on your system.

Step4: To configure Java default variables.

To automatically set up the Java 7 environment variables JAVA_HOME and PATH:

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

To automatically set up the Java 8 environment variables JAVA_HOME and PATH:

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

Enjoy the power of Java on your system. For any assistance or problem ask me in the comment box.


Mohd Sohail is a web developer and a Linux sysAdmin. He also loves to write how-to articles, applications reviews and loves to use new Linux distributions.

Articles: 859


Leave a Reply

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