JAVA LINUX Oracle Ubuntu

How To Install Oracle Java 8 in Ubuntu 16.04

Ubuntu Application Launchers
Ubuntu Application Launchers

How To Install Oracle Java 8 in Ubuntu 16.04

Oracle’s Java eight could be a artificial language that makes several of the applications and websites in use these days. Its present and stable nature makes it a favorite amongst Google and golem developers for the last twenty years. If you have got a Liquid internet Core Managed Ubuntu sixteen.04 LTS server, contact our support team for facilitate with installation. Otherwise, this tutorial guides you thru the way to install Java eight(Java Development Kit) and set the trail of the JAVA_HOME variable.

Pre-Flight Check

  1. Open the terminal and log in as root.  If you are logged in as another user, you will need to add sudo before each command.
  2. Working on a Linux Ubuntu 16.04 server
  3. No installations of previous Java versions

Install Oracle Java 8

Step 1:  Update & Upgrade

It is advised to update your system by copy and pasting the command below.  Be sure to accept the update by typing Y when asked to continue:

apt-get update && apt-get upgrade

Step 2: Install the Repository

WebUpd8 Team Personal Package Archive (PPA), a third-party repository, allows us to download the package necessary for Java 8 installation.  Press Enter to continue the installation.

add-apt-repository ppa:webupd8team/java

Once again, update your package list.

apt-get update

Step 3: Install Java 8

Use the apt-get command to install Oracle’s Java 8 via their installer:

apt-get install oracle-java8-installer

Click Y to continue and press Enter to agree to the licensing agreement.

configuring-oracle

Select Yes and hit the Enter key.

configuring-oracle-java

Step 4: Verify Java 8 is Installed

java -version

Output:

java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

Set Java’s Home Environment

It’s essential to know the path of our Java installation for our applications to function. Where is Java installed? Run this command to find its path:

update-alternatives --config java

Output:

~# update-alternatives --config java
There is 1 choice for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 auto mode
* 1 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 manual mode

Copy the highlighted path from the second row: /usr/lib/jvm/java-8-oracle/jre/bin/java/.  After copying, open the file /etc/environment and add in the path of your Java installation to the end of your file.

vim /etc/environment
JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre/bin/java"

Save the file by hitting ESC button and type :wq to execute the command below to recognize the changes to the file:

source /etc/environment

You should now see the path of installation when using the $Java_Home variable:

echo $JAVA_HOME

Output:

~# echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle/jre/bin/java
READ  Set Up Let's Encrypt with Nginx Server Blocks on Ubuntu 16.04

About the author

Venkatesan Prabu

Venkatesan Prabu

Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.

Add Comment

Click here to post a comment