How to Install Oracle Java SE 8 on Ubuntu 14.10

Ubuntu Linux

You just installed Ubuntu 14.10 Utopic Unicorn and then want to install NetBeans or Eclipse to develop Java / Android applications. What you need to do firstly is install Oracle Java SE 8 / JDK 8 (at the time of this writing, the latest version of Java is Java SE 8). This tutorial shows you how to install Oracle Java SE 8 on Ubuntu 14.10.

When you run ‘java‘ via Terminal in the default installation of Ubuntu, you will get message that java is not installed and can be found in some packages:

$ java -version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.8-jre-headless
 * gcj-4.9-jre-headless
 * openjdk-7-jre-headless
 * openjdk-6-jre-headless
 * openjdk-8-jre-headless
Try: sudo apt-get install <selected package>

We don’t want the OpenJDK, we want to install the Oracle JDK instead.

1. Download the Oracle Java SE / JDK from here.

2. Extract the downloaded file, I prefer move it to /usr/local/ directory, create symbolic link, and update the $PATH

$ tar zxf jdk-8u25-linux-x64.tar.gz 
$ sudo mv jdk1.8.0_25 /usr/local/
$ sudo ln -sf /usr/local/jdk1.8.0_25 /usr/local/java
$ export PATH=$PATH:/usr/local/java/bin

3. Verify the installed Java

$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

$ which java
/usr/local/java/bin/java

4. Make it runs at boot

The $PATH will reset to default if the system reboot. To prevent this, we need to make it runs at boot time by adding the following line in $HOME/.profile file.

export PATH="$PATH:/usr/local/java/bin"

Now you are ready to install NetBeans, Eclipse, or any Java IDE to develop Java or Android applications.