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.
- 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
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.
Before you download the file, note its byte size provided on the download page on the website. Next, go to http://java.com 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.
Step 3. Change Directories
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:
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 "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 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.
Step 4. Next, execute the source command below to accept the changes to the file.
Finally, we should see the installation path when running the echo command with the $JAVA_HOME variable.
~# echo $JAVA_HOME /usr/lib/jvm/java-8-oracle/jre/bin/java
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 firstname.lastname@example.org, by phone (at 800-580-4986) or via a LiveChat for whatever method you prefer. We work hard for you so you can relax.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.