Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.

In this guide, we will explain how to install and configure Java on a Debian 9 server.

To install Java on CentOS 7, you can follow the guide here

To install Java on Ubuntu 16/18, you can follow the guide here

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can quickly deploy your cloud servers.

Once you have signed up, log into your Cloudwafer Client Area and deploy your Cloudwafer cloud server.

Updating System Packages
It is recommended that you update the system to the latest packages before beginning any major installations. Issue the command below:

sudo apt-get update && sudo apt-get upgrade

Step 1: Install OpenJDK 8
The default Java development and runtime in Debian 9 is OpenJDK 8 an open-source implementation of the Java Platform. Issue the command below to install OpenJDK 8 JDK from the standard Debian repositories:

sudo apt install default-jdk


After installation, issue the command below to verify our installation and check the Java version:

 java -version


Installing the Oracle JDK
We will be installing the Oracle JDK from Azul Systems PPA which provides tested, certified builds of OpenJDK, under the name of Zulu. Zulu is free and open-source software (and freely redistributable) and offers up to date OpenJDK builds of Java 12, 11, 8, and 7.

Import the Azul Systems PPA public key and enable the repository with the following commands:

sudo apt-key adv --keyserver hkp:// --recv-keys 0xB1998361219BD9C9

echo "deb stable main" | sudo tee /etc/apt/sources.list.d/zulu.list

Next, update the packages list before installing the oracle-jdk-12 package:

sudo apt update

sudo apt install zulu-12


After installation, issue the command below to verify our installation and check the Java version:

 java -version


Switching multiple versions of Java
In this guide, we have installed various Java installations on one server. You can configure which version is the default for use in the command line by using update-alternatives, which manages which symbolic links are used for different commands.

sudo update-alternatives --config java

Select the number to use as a default.