Install Oracle Java 8
Ubuntu has OpenJDK installed by default, but in certain cases you might need to install Oracle Java instead. It is possible to install Oracle Java manually, however the process is a bit lengthy and requires a lot of steps.
Oracle Java can be downloaded from the official website over here -
However in this post we shall be installing Oracle Java using a ppa package maintained by the WebUp8 team. The package downloads the latest oracle java builds in the background and then installs and configures it.https://launchpad.net/~webupd8team/+archive/ubuntu/java
First check your existing java installation with the java command -
$ java -version java version "1.7.0_95" OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.15.10.1) OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
In the above example OpenJDK is installed already, and is going to be replaced with Oracle Java.
The following steps should work on Ubuntu 15.10 or Linux Mint 17 and other similar Ubuntu based linux distros.
1. Setup the PPA
This first thing to do is to setup the webupd8 ppa on your system. Run the following command and proceed.
$ sudo apt-add-repository ppa:webupd8team/java $ sudo apt-get update
After setting up the ppa repository, update the package cache as well.
2. Install the Java 8 installer
Now install the package named "oracle-java8-installer". This installer is going to download the actual Oracle JDK from the Oracle website. It should finish in a couple of minutes depending on your internet speed
$ sudo apt-get install oracle-java8-installer
After the installation is finished, Oracle Java is setup. Run the java command again to check the version and vendor.
$ java -version java version "1.8.0_91" Java(TM) SE Runtime Environment (build 1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
The above output indicates Oracle Java.
3. Setup Oracle Java as the default
The ppa repository contains another package, that sets Oracle Java as the default java runtime. Install it with the following command -
$ sudo apt-get install oracle-java8-set-default
You might prefer to remove the existing OpenJDK package before installing Oracle Java. To remove the OpenJDK packages run the following command -
$ sudo apt-get purge openjdk-*
If you wish to install Oracle Java manually using the packages from Oracle's website then check out this tutorial on stackoverflow over here.
If you have other questions on the above, please feel free to leave a comment below.