You can install Java based on your requirements. As an example, to run a java application you only need to install JRE (Java Runtime Environment) but for the development system, you need the JDK (Java Development Kit). You can either install OpenJDK or Oracle Java on your system. This tutorial covers both options for you.

Installing OpenJDK

OpenJDK is an open source implementation of the Java Platform standard edition. You can install it directly from the default repository on Debian 9 system. Install JRE: Install JDK:

Installing Oracle JAVA

You need to configure Apt repository on your system first before beginning Java installation on Debian 9. Execute following commands to import signing key and add Java PPA on Debian. Then install Java on your system. The package oracle-java8-installer is not actual Java package, It contains scripts which automatically configure Java on Debian 9 system. You can also install Java 10 on Debian 9 using these instructions.

Switch Between Multiple Java Versions

At this step, you have installed multiple java versions on your system. But you need to switch to different Java version. Let’s execute below command from terminal and choose appropriate installed Java on Debian 9.

See the above screenshot, I choose 2 which will configure Oracle Java 8 as default version on my Debian system.

How to Install Java on Debian 9  Stretch    TecAdmin - 99