Install Java on Debian 9

Java is the popular programming language owned by Oracle. Java is used to build cross-platform applications. Over 3 billion devices run on Java. In this tutorial, we are going to install Java on Debian 9 using different methods.

Java has following three editions:

Standard Edition(SE).

Micro Edition(ME).

Enterprize Edition(EE).

Following two implementations available for Java:

Oracle Java.

OpenJDK Java.

In this tutorial we are going to install Standard Edition (SE). There is no more difference in Oracle Java and OpenJDK Java as Oracle Java provides some additional enterprise features.

Prerequisites

Before you start to install Java on Debian 9. You must have the non-root user account on your system with sudo privileges.

Install Default OpenJDK

Currentally, OpenJDK 10 is the default version for Debian 9. To install OpenJDK 10 run following commands.

Update the package manager index typing following command.

sudo apt update

Enter the following command to install Default OpenJDK on Debian 9.

sudo apt install default-jdk

Confirm the installation and check the version typing following command.

Install OpenJDK 8, 10, or 11

You can install the specific version of OpenJDK by using the following command. Replacing [VERSION_NUMBER] with the version number you want to install.

sudo apt install openjdk-[VERSION_NUMBER]-jdk

For example, if you want to install OpenJDK 8 which is the current LTS version of OpenJDK then just run following command.

sudo apt install openjdk-8-jdk

Install Java From Oracle Website

As web8team repository only contains Java 8. If you want to install Java 10 then download the package from Oracle Official Website. Here we are going to install Java 10 while you can choose another version.