This tutorial will help to install JAVA (OpenJDK) on all versions of Debian 10 Buster system. You can also use this tutorial to install Java on any Debian based systems. Let’s follow the below simple steps for the installation.
For the Oracle Java installation, users can use below link to install Oracle Java on Debian 10 system.
Step 1 – Search OpenJDK Packages
OpenJDK packages are available under native apt repositories. You can simply use
apt search openjdk
As per above output, you can see
Step 2 – Install Java on Debian 10
Use the below command to install OpenJDK on your Debian 10 Buster systems using the package manager from the default repository. The below commands will install Java Development Kit (JDK) and Java Runtime Environment (JRE) both on your system. You can install JRE package only to setup Runtime Environment only.
sudo apt install openjdk-11-jdk
Wait for the completing installation.
Step 3 – Configure Default Java Version
The newly installed OpenJDK Java 11 will be configured as default Java version. But in some cases, you may need to change the default Java version. Run the following command on terminal:
update-alternatives –config java
This will list all configured Java versions on your system. Choose the appropriate version number as showing in below screenshot.
A star (*) shows the currently active version. Here I choose 0 for OpenJDK 11 and press enter.
After installation of Java uses below command to verify the installed version of Java on your system.
java -versionopenjdk version "10.0.1" 2018-04-17 OpenJDK Runtime Environment (build 10.0.1+10-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 10.0.1+10-Ubuntu-3ubuntu1, mixed mode)
Step 4 – Set JAVA_HOME
Its the best practice to set Java environment variable after installing java. To setup
JAVA_HOME add following line to
/etc/environment file, Path may be differ with your system architecture.
echo "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/" >> /etc/environment source /etc/environment
Use the following command to check the environment value