How to Install Java 10 on Debian 9

how to install java 10 on debian 9

install java debian 9In this tutorial, we are going to discuss the process of installing Java on Debian 9. Java is a general-purpose programming language developed by Sun Microsystems before being bought by Oracle, who maintain and develop Java to this day. Distinguished as a fast, secure, and reliable language available on all platforms, Java can be established on anything from laptops to game consoles, to computers and cell phones. Since Java code is compiled as bytecode before being executed in a Java Virtual Machine (also known as a JVM), this allows Java programs to be run on any computer architecture with no compatibility barriers.

install java debianThanks to its object-oriented nature, ease-of-use, and wide cross-platform compatibility, all of these factors make Java a very appealing choice of programming language for most developers. Another great pro when using Java is the community: hundreds of thousands of developers have used Java, and countless Java libraries have been created to perform specific tasks, allowing you to create your programs with ease. Oracle also often updates their programming language, further optimizing its speed, while also adding features to further improve the Java experience. To put the cherry on top, it’s free to download. An open-source version of Java also exists and is run by Oracle as well. Known as OpenJDK, it is also completely free and has its source code open for the entire world to see.

installing java debianInstalling Java on Debian server is easy – however, it’s important to know which ‘type’ of Java you need. First, there is the JRE (the Java Runtime Environment), which is just the Java Virtual Machine, used to run Java programs on the machine. The other type of Java is the JDK (the Java Developer Kit). This includes the JRE, plus the necessary tools that will allow you to develop and compile Java programs that can then be run on any platform with the JRE. It is also important to know which variant of Java you need. The OpenJDK is an open-source variant of Java that is developed and maintained by Oracle. The classic Oracle JDK is the closed-source in-house version of Java developed entirely by Oracle. Oracle Java is more oriented towards the enterprise market, with longer version support lifespans than OpenJDK. We will cover the installation process for all types and variants, allowing you to choose exactly which flavor of Java you wish to have installed.

Installing the OpenJDK version of Java.

Method 1: Install using apt-get.

Note: Installing using this method may not lead to Java 10 being installed. Since the version is dependent on what version is available from the repositories, it is possible that you will end up installing Java 8 or 9 instead of 10.

Installing the JRE:

The Java Runtime Environment normally comes preinstalled on a default installation of Debian 9. However, if you do not have it pre-installed, you can easily install it through apt-get and the pre-loaded repositories.

You may need to use apt-get as a root user in order to install the JRE. To log in as the root user, enter the command found below:

su -

To install the Java Runtime Environment, just execute the following command:

apt-get install default-jre

Installing the JDK  10 on Debian 9:

The JDK 10 is not pre-installed on Debian 9 by default.

To install the Java Developer Kit (JDK),  execute this command:

apt-get install default-jdk

Method 2: Manual installation of OpenJDK 10 on Debian 9

By manually installing the OpenJDK yourself, you ensure that Java 10 will be the version that is installed.

Step 1: Download and extract the OpenJDK tarball.

Go to the download page for the OpenJDK software package, and right click on the tar.gz link found to the right of the “Linux” option. Click on “Copy link address” or “Copy link”. Now, open a terminal if you are on a desktop Debian machine, or log into your Debian server using SSH. Download the tarball by entering the following command:

wget <paste the download link here>

Create a directory where you wish to install your OpenJDK environment:

mkdir <enter the path and directory name here>

Then, extract the tarball to your new directory by entering the following command:

tar xvzf openjdk-10.0.1_linux-x64_bin.tar.gz -C <the path to your new directory>

Once this is done, you can now add the extracted folder to your path variable. This allows you to run java commands from anywhere in the system.

Step 2: Add the new directory to your path variable.

Create a new file in /etc/profile.d/ named “jdk10.sh”. The full path should be “/etc/profile.d/jdk10.sh”. Then, enter these next two lines in the file:

export JAVA_HOME="<insert install directory here>/jdk-10.0.1"
export PATH="$PATH:${JAVA_HOME}/bin"

Save the file, and then restart your desktop/server for the changes to take effect. Now, check whether your java environment has been successfully set up by trying the following command:

javac -version

The output should read: “javac 10.0.1”. You have now successfully installed OpenJDK on your Debian 9 system.

Installing the Oracle version of Java 10 on Debian 9

Step 1: Download and extract the Oracle JDK tarball.

Go to the download page for the Oracle JDK software packages. First, click on “Accept License Agreement” in order to unlock the downloads. After that, right click on the file ending with “…linux-x64_bin.tar.gz”, and click on “Copy link address” or “Copy link”. Then, open a terminal if on a desktop, or SSH into your Debian server, and enter the following command:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" <paste the download link here>

Then, create a new directory where you would like your Java environment to be installed. Now, we can extract the Oracle JDK tarball to the new directory by entering the following command:

tar xvzf jdk-10.0.1_linux-x64_bin.tar.gz -C <the path to your new directory>

Once this is done, you can now add a shortcut to the extracted folder in your path variable. This allows you to run java commands as if you installed them using apt-get.

Step 2: Add the new directory to your path variable.

Create a new file in /etc/profile.d/ named “jdk10.sh”. The full path should be “/etc/profile.d/jdk10.sh”. Then, enter these next two lines in the file:

export JAVA_HOME="<insert install directory here>/jdk-10.0.1"
export PATH="$PATH:${JAVA_HOME}/bin"

Save the file, and then restart your desktop/server for the changes to take effect. Now, check whether your java environment has been successfully set up by trying the following command:

javac -version

The output should read: “javac 10.0.1”. You have now successfully installed OpenJDK on your Debian 9 system.


install java 10 on debian 9Of course, you don’t need to install Java 10 on your Debian 9 machine yourself if you have a high-speed Debian VPS hosted with us – in which case, you can contact our team of Linux experts who can install and configure either version of Java for you. They are available 24/7 and can help with any requests or questions that you may have.

PS. If you liked this post, feel free to share it by using the social media share buttons below, or simply leave a comment. Thanks.

Leave a Comment