Install Oracle Java 8 onto Ubuntu 16.04

If you need to install Oracle Java 8 on Ubuntu – you need to do 3 things.

What is a JRE – a Java Runtime Engine

Java software doesn’t arrive in a format that machines understand, – an intermediary – a runtime engine – is needed to translate what is known as “Bytecode”, into the machine code language that a machine speaks.

This precept is a good thing, it makes JAVA software portable, software written in 100% Java can run on any operating system (Windows, iOS, Linux, Android) that has a JRE – a Java Runtime Engine.

Installing Java 8 With a Script

Oracle Java prompts for user input so if you want to script (automate) the Java 8 install – use the below commands.

$ sudo add-apt-repository ppa:webupd8team/java -y
$ sudo apt-get update
$ accept-license = "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true"
$ echo "$accept-license" | sudo debconf-set-selections
$ sudo apt --assume-yes install oracle-java8-installer

Notice that we used the -y flag when adding the repository and the --assume-yes modifier when installing. We also employed some debconf-set-selections magic to answer “yes” on the prompt that asks you to accept the license terms.

The java version command should tell you that you have installed Java Oracle 8 onto your Ubuntu server.

$ java -version

Installing Java 8 onto Ubuntu 16.04 in 3 Steps

These instructions are good for any Linux operating systems with a Debian ilk. For peace of mind – these install instructions have been heavily tested against the Ubuntu 16.04 and Ubuntu 15.04 operating systems.

Note that this install will make Java 8 the default Java runtime (JRE) on the machine.

Step 1 = Add Oracle Java 8 Repository to apt-get

Run this command.

sudo add-apt-repository ppa:webupd8team/java

You will need to accept the terms and conditions from Oracle.

Step 2 = Update the package database

sudo apt-get update

Step 3 = Install Java 1.8

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

You will need to give the go-ahead again. You will see a line that includes the following text.

(3.53 MB/s) – ‘jdk-8u77-linux-x64.tar.gz’ saved

That’s it! Just do your checks and you are done. Lights out and away you go!

Check Step – Is Java 8 Running?

To check that you machine is running Java version 8 execute this command.

java -version

The output saying that Java 1.8 has been installed on Ubuntu will be similar to this.

java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

Leave a Reply

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