How to Install Java on Ubuntu 18.04

r00t May 5, 2018

Install Java on Ubuntu 18.04

In this tutorial we’ll learn how to install Java on Ubuntu 18.04. We will also install and configure its prerequisites. 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.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 18.04 LTS minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Java on Ubuntu 18.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y

Step 2. Installing Java on Ubuntu 18.04 LTS.

Add the Webupd8 Team PPA repository, run the following commands on your server:

apt-get install software-properties-common
apt-add-repository ppa:webupd8team/java

Run commands to update system package index and install Java installer script:

apt-get update
apt-get install oracle-java9-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:

update-alternatives --config java

To check the Java version after installing the package, run command:

### java --version
java 9.0.4
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

Step 3. Setup JAVA_HOME on Ubuntu 18.04.

The PPA also contains a package to automatically set Java environment variables, just run command:

apt-get install oracle-java9-set-default

Congratulation’s! You have successfully install and configured Java (JRE or JDK) on your Ubuntu 18.04 Bionic Beaver server. Thanks for using this tutorial installing Java on Ubuntu 18.04 LTS (Bionic Beaver) system.


The Tags:

Leave a Comment

Comments are closed.