Oracle’s 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.
- 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.
- Working on a Linux Ubuntu 16.04 server
- 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 Java 8
This procedure uses a tar.gz install of the Java Runtime Environment (JRE) for 64-bit Linux, using an archive binary file.
- Go to http://java.com and click on the Download button.
- Download and check the download file size to ensure that you have downloaded the full, uncorrupted software bundle. Before you download the file, note its byte size provided on the download page on the website. Once the download has completed, compare that file size to the size of the downloaded file to make sure they are equal.
These instructions are for installing version 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.
Now, cd into the directory in which you want to install Java. Type in:
For example, to install the software in the /usr/java/ directory, Type:
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 this example, it is installed in the /usr/java/jre1.8.0_73 directory. When the installation has completed, you will see the word Done.
Finally, Delete the .tar.gz file if you want to save disk space.
Verify Java 8 is Installed
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
~# 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
Next, copy the highlighted path from the second row:
After copying, open the file
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"
Then, save the file by hitting the ESC button and typing :wq to exit vim.
Next, execute the command below to recognize the changes to the file:
You should now see the path of installation when using the $Java_Home variable:
~# echo $JAVA_HOME /usr/lib/jvm/java-8-oracle/jre/bin/java
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 email@example.com, by phone (at 800-580-4986) or via a LiveChat for whatever method you prefer. We work hard for you so you can relax.