Java Illustration by Walker Cahall

Java Illustration by Walker Cahall

Verified and Tested 03/4/16


If you had the option to choose between a base model car or a fully loaded model, which one will you choose?

Both cars will take you from point A to point B, but with the fully loaded car you have additional features that can make rush hour a chill hour.

Well, that’s the same concept when we take a closer look at Java. There are two standard types of installations, JRE (Java Runtime Environment) and JDK (Java Development Kit). Like the base model car, JRE enables the ability to create Java Applications for different types of deployments using minimal core tools to accomplish the task. JDK is a fully loaded Development Kit that has everything that JRE has plus additional resources to create/secure Applications and Applets.


You need a Ubuntu server that is configured with a static IP address.  If you do not have a server already, why not spin up a robust and reliable Cloud Server in under 30 seconds.

Installing Java on Ubuntu 16.04

Before we begin, let make sure that the server is fully updated with the following command:

sudo apt update

After your server has been fully updated, you will need to know what version of Java is currently installed or if it is not installed, with the following command:

java -version

Install Java Open JRE or JDK on Ubuntu 16.04

Once you have verified if Java is installed or not, choose the type of Java installation that you want with one the following:

sudo apt install default-jdk
sudo apt install default-jre

One alternative Java install is with Open JRE 7 and JDK 7 and can be installed with one of the following:

sudo apt install openjdk-7-jre
sudo apt install openjdk-7-jdk

Install Java Oracle JRE or JDK on Ubuntu 16.04

Another alternative Java install is with Oracle JRE and JDK. However, we would need to install additional repositories for a proper installation.

sudo apt install python-software-properties
sudo add-apt-repository ppa:webupd8team/java

Then, you will need to fully update the system with the following command:

sudo apt update

You can also install previous and newer versions of Java by using one of the following commands:

sudo apt install oracle-java6-installer
sudo apt install oracle-java7-installer
sudo apt install oracle-java8-installer

If you have multiple versions of Java installed on your server, then you have the ability to select a default version. Check your alternatives with the following command:

sudo update-alternatives --config java
This is the output after running the Java Alternative script on Ubuntu 16.04

This is the output after running the Java Alternative script on Ubuntu 16.04

Once you have viewed your alternatives, choose the version that you want by selecting the assigned number, and then hit enter.

Setup JAVA_HOME on Ubuntu 16.04

Since many programs now days need a JAVA_HOME environment variable to work properly. We will need to find the appropriate path to make these changes. With the following command, you can view your installs and their path:

sudo update-alternatives --config java

To edit the environment file use your text editor and edit the following file:

sudo nano /etc/profile

Now that you are in the user profile file, add the following code, along with the Path of your installation from the previous step, to the bottom. ( Example: JAVA_HOME=”YOUR_PATH”)

export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-"

Reload the file so all your changes could take effect with the following command:

source /etc/profile

Verify that your implementations are correct with the following command. Confirm :


What Next?

Congratulations! You now have a successfully installed Java on your Ubuntu 16.04 server. Thank you for following along and feel free to check back with us for further updates.