How To Install Oracle Java on Ubuntu or Debian

Java is a programming technology originally developed by Sun Microsystems and later acquired by Oracle. Oracle Java is a proprietary implementation for Java that is free to download and use for commercial use, but not to redistribute, therefore it is not included in a officially maintained repository. In this tutorial, we will discuss about “How To Install Oracle Java on Ubuntu or Debian” systems.

Please note that following tutorial is applicable for Fedora, Ubuntu and (perhaps) Linux Mint. I have tried these steps on Ubuntu 14.04.

Before we go on seeing the process to install Java, let’s quickly understand the difference between JRE, OpenJDK and Oracle JDK.

JRE (Java Runtime Environment) is what you would need normally to run a Java based application. This is all you need if you are not a programmer.

JDK stands for Java Development Kit and this is what you need to if you have to do some development (read programming) related to Java.

OpenJDK is Open Source implementation of Java Development Kit while Oracle JDK is the official Oracle version of Java Development Kit. While OpenJDK is sufficient for most of the cases, some programs such Android Studio suggests to use Oracle JDK to avoid UI/performance issue.

There are many reasons why you would want to install Oracle Java over OpenJDK.

Setting Oracle JDK as the default JVM

Once you have installed the JDK in /opt directory, you need to update your system environment to use this JDK. In our case, the java executable is located under /opt/jdk/jdk1.8.0_102/bin/java . To set it as the default JVM in your machine run following command:

(Optional) Updating Java

To update Java, simply download an updated version from Oracle’s website and extract it under the /opt/jdk directory, then set it up as the default JVM with a higher priority number (in this case 110):