Reading Time: 4 minutes

The Oracle Java 8 is a programming language that creates many of the applications and websites in use today.  Its ubiquitous and stable nature makes it a favorite amongst Google and Android developers for the last 20 years. If you have a Liquid Web Core Managed Ubuntu LTS VPS server, contact our support team for help with installation.  Otherwise, this tutorial guides you through how to install Java 8 (Java Development Kit) and set the path of the JAVA_HOME variable.

PreFlight Check

  • Open a terminal and log in as root.  If you are logged in as another user, you will need to add sudo before each command.
  • We will be working on a Liquid Web Core-Managed Linux Ubuntu 16.04 LTS server
  • No installations of previous Java versions

Install Oracle Java 8

Update & Upgrade

It is always advised to update our system prior to beginning any changes.  Be sure to accept the update by typing Y when asked to continue:

apt-get update && apt-get upgrade
Important Oracle Java License Update: The Oracle Java License has changed for releases starting April 16, 2019. The new Oracle Technology Network License Agreement for Oracle Java SE is substantially different from prior Oracle Java licenses. The new license permits certain uses, such as personal use and development use, at no cost — but other uses authorized under prior Oracle Java licenses may no longer be available. Please review the terms carefully before downloading and using this product. An FAQ is available here. Commercial license and support is available with a low cost Java SE Subscription. Oracle also provides the latest OpenJDK release under the open source GPL License at

Install Java 8

Step 1. Download

This procedure uses a tar.gz install of the Java Runtime Environment (JRE) for 64-bit Linux, using an archive binary file.

Prior to the file being downloaded, we must accept the license agreement. The binary itself can be installed by anyone (not only root users), in any location where we can write to. However, only the root user can install the JDK into the system location.

Before you download the file, note its byte size provided on the download page on the website. Next, go to and click on the Download button.

Now, download the tar.gz file of your choosing and then verify the size of the file to ensure that you have downloaded the full, uncorrupted software bundle.

Step 2. Install

These instructions are for installing Java 8 Update 73 (8u73). If you are installing another version, make sure you change the version number appropriately when you type the commands at the terminal. 

Example: For Java 8u79 replace 8u73 with 8u79. Note that, as in the preceding example, the version number is sometimes preceded with the letter u, and sometimes it is preceded with an underbar, for example, jre1.8.0_73.

To install Java in a system-wide location such as /usr/local, you must login as the root user to gain the necessary permissions. If you do not have root access, install Java in your home directory or a subdirectory for which you have write permissions.

Step 3. Change Directories

Now, cd into the directory in which you want to install Java. Type in:

cd /directory/path/name

For example, to install the software in the /usr/java/ directory, Type:

cd /usr/java/

Step 4. Unpack the Tarball and Install Java

Next, we want to move the downloaded .tar.gz archive binary to the current directory.

tar zxvf jre-8u73-linux-x64.tar.gz

The Java files will be installed in a directory called jre1.8.0_73 in the current directory. In the example above, it is installed in the /usr/java/jre1.8.0_73 directory. When the installation has completed, you will see the word "Done".

Step 4. Remove the File

Finally, delete the .tar.gz file to save disk space.

Step 5. Verify Java 8 is Installed

java -version


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

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

update-alternatives --config java


~# 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

Step 2. Next, copy the highlighted path from the second row:

Step 3. After copying the file path, use vim to edit the /etc/environment file. Now, we will add in the path of our Java installation to the end of our file.

vim /etc/environment

#add to end of file

Then, save the file by hitting the ESC button and typing :wq to exit vim.

Step 4. Next, execute the source command below to accept the changes to the file.

source /etc/environment

Finally, we should see the installation path when running the echo command with the $JAVA_HOME variable.



~# echo $JAVA_HOME

Final Thoughts

Installing the Java software automatically creates a directory called jre1.8.0_version. If we try to install the Java SE Runtime Environment as a user into a system-wide location such as /usr/jre, we must first become root to gain the necessary permissions. When we do not have access to the root user, we can simply install the Java SE Runtime Environment into our home directory, or a subdirectory in which we have permission to write to.

Installing the software in a directory that already contains a subdirectory named jre1.8.0_version, the new software installation will overwrite the existing files of the same name in that jre1.8.0_version directory. If the folder contains files we want to keep, rename the old directory to jre1.8.0_old_version or a name of your choosing.

Lastly, the installation script configures the system in a way that the backing store for the system preferences is created inside the JRE's installation directory. If JRE installation is installed on a network-mounted drive, both it and the system preferences can be exported to sharing with the Java runtime environments on other machines.

See the Java documentation for more preferences.

The Most Helpful Humans In Hosting™

We pride ourselves on being The Most Helpful Humans In Hosting™! Our support staff is always available to assist with any Dedicated, Cloud, or VPS server issues 24 hours a day, 7 days a week 365 days a year.

We are available, via our ticketing systems at, by phone (at 800-580-4986) or via a LiveChat for whatever method you prefer. We work hard for you so you can relax.

Avatar for David Singer

About the Author: David Singer

I am a g33k, Linux blogger, developer, student, and former Tech Writer for My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Latest Articles

How to install Puppet Server on Linux (AlmaLinux)

Read Article

Deploying web applications with NGINX HTTP Server

Read Article

Email security best practices for using SPF, DKIM, and DMARC

Read Article

Linux dos2unix command syntax — removing hidden Windows characters from files

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article