Install Oracle Java 8 on Ubuntu, Linux Mint, Elementary OS

In this tutorial, I will show you how to install Oracle Java 8 on Ubuntu based Linux distributions, including  Ubuntu 16.04/14.04, Linux Mint, Elementary OS, from PPA (Personal Package Archive). The following will be installed on your system once you finish this tutorial.

  • Java JDK (Java Development Kit)
  • JRE (Java Runtime Environment)
  • Java browser plugin

Programs written in Java such as phpStorm can run on any operating system that has Java installed.

Install Oracle Java 8 on Ubuntu/Linux Mint/Elementary OS

Run the following 3 commands one by one in your terminal to add the PPA and install Oracle Java8.

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install java-common oracle-java8-installer

The 3rd command will install the Oracle Java8 installer and itself will download Oracle Java 8 binary and then install it on your system. During the installation phase, you need to accept the Oracle binary code license terms.

Install Oracle Java 8 on Ubuntu

Check Version Number

Once the installation is complete, we can check Java version.

java -version

Install Oracle Java 8 on Ubuntu

Check Java compiler version

javac -version

Install Oracle Java 8 on Ubuntu

Set Environment Variable.

Run the following command to set environment variable.

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

Once installed, there will be two new files under /etc/profile.d/ directory: jdk.csh and These two files are shell scripts that contains commands to set 5 environment variables.

cat /etc/profile.d/


export J2SDKDIR=/usr/lib/jvm/java-8-oracle
export J2REDIR=/usr/lib/jvm/java-8-oracle/jre
export PATH=$PATH:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export DERBY_HOME=/usr/lib/jvm/java-8-oracle/db

We need to reload /etc/profile to let these environment variables to take effect.

source /etc/profile

Now you can check these 5 environment variables like below:


Set Environment Variable.

As you can see, it’s easy to install Oracle Java 8 on Ubuntu, Linux Mint and Elementary OS once you read this tutorial. Comments, questions or suggestions are always welcome. If you found this post useful, ? please share it with your friends on social media! Stay tuned for more Linux tutorials.

Rate this tutorial
[Total: 40 Average: 4.7]

4 Responses to “Install Oracle Java 8 on Ubuntu, Linux Mint, Elementary OS

  • don’t work on elementaryOS

    “sudo: add-apt-repository: command not found” is the error im getting trying to install the first line…and it was a straight copy/paste.


    • Xiao Guo-An (Admin)
      5 years ago

      Run the following command first.

      sudo apt install software-properties-common
  • Works 100% on ElementaryOS Juno! You’re my hero!

  • LinuxUser
    5 years ago

    :O works on Elementary os Juno

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community ( for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here