nordvpn

How to install OpenJDK 8 on Debian 10 (Buster)

How to install OpenJDK 8 on Debian 10 (Buster)

In this tutorial, I will show you how to install OpenJDK 8 on Debian 10 (Buster). The Java Development Kit (JDK) is a software development environment used for developing Java applications and applets. It includes the Java Runtime Environment (JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc) and other tools needed in Java development.

Pre-requisites

    • Debian 10 (Buster) install with root access
    • apt install -y wget gnupg software-properties-common

Read Also: Install postgreSQL 11 on Debian 10 (Buster)

1. Add AdoptOpenJDK Repo

We need to add adopt OpenJDK repo in order to install OpenJDK 8 on Debian.

wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -

sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/

2. Install Java 8

Here we will use apt to install Java 8 on Debian Buster

$ apt update -y

$ apt install adoptopenjdk-8-hotspot -y

3. Check java Version

Now after installing open JDK check the version using the following command

$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.222-b10, mixed mode)

Read Also: How to install Java 11 on CentOS 7

4. Set Java Home Environment

We need to set Java Home Environment Variable in order to use java with some applications. Let’s get started.

$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Nothing to configure.

Option 1: Set Environment Variable

$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Option 2: Adding in .bash_profile

In this option, I will add an entry in .bash_profile.

$ vim ~/.bash_profile

and paste the following and save and quit.

$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Now source the file.

$ source ~/.bash_profile

Now check the Java Home

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

If you have any issues using this tutorial please feel free to comment below.

Reference: use this link

Add to Slack

 

7 Comments Posted

  1. $ apt install openjdk-8-jdk

    Casues:

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package openjdk-8-jdk

    Debian 10 starts at Java11, apparently, so this doesn’t actually work, unless you changed something else

    • Hey Sam,

      I can install it by using all the above commands.
      apt list --installed | grep jdk
      adoptopenjdk-8-hotspot/buster,now 8u232-b09-2 amd64 [installed]

  2. Hey, this worked perfectly! Thank you for publishing this info. I installed Java 8 and then went to install Minecraft and everything worked first time!
    The ‘vim’ problem noted by someone earlier was good to know, I used gedit instead. Thank you!

Leave a Reply

Your email address will not be published.


*



The reCAPTCHA verification period has expired. Please reload the page.

48-Hour Flash Sale! Courses from just $10.99