Categories
DevOps

How to install OpenJDK 8 on Debian

Use AdoptOpenJDK/Eclipse Adoptium to install OpenJDK 8 (LTS)/OpenJDK 11 (LTS) or OpenJDK 15 (Latest) using Eclipse OpenJ9 or HotSpot Java virtual machine.

Prerequisites

Install required packages.

$ sudo apt-get install curl gnupg apt-transport-https

Install Java

Import AdoptOpenJDK GPG public key using curl.

$ curl --silent https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
OK

Define AdoptOpenJDK repository.

$ cat <<EOF | sudo tee -a /etc/apt/sources.list.d/adoptopenjdk.list
deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ $(lsb_release  --codename --short) main
EOF
deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ buster main

Update package index.

$ sudo apt update
Hit:1 http://deb.debian.org/debian buster InRelease
Hit:2 http://security.debian.org/debian-security buster/updates InRelease
Get:3 https://adoptopenjdk.jfrog.io/adoptopenjdk/deb buster InRelease [6,155 B]
Get:4 https://adoptopenjdk.jfrog.io/adoptopenjdk/deb buster/main amd64 Packages [13.1 kB]
Fetched 19.3 kB in 1s (16.8 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done

Search for AdoptOpenJDK packages.

$ apt-cache search adoptopenjdk
adoptopenjdk-11-hotspot - OpenJDK Development Kit 11 (JDK) with Hotspot by AdoptOpenJDK
adoptopenjdk-11-hotspot-jre - OpenJDK Runtime Environment 11 (JRE) with Hotspot by AdoptOpenJDK
adoptopenjdk-11-openj9 - OpenJDK Development Kit 11 (JDK) with Eclipse OpenJ9 by AdoptOpenJDK
adoptopenjdk-11-openj9-jre - OpenJDK Runtime Environment 11 (JRE) with Eclipse OpenJ9 by AdoptOpenJDK
adoptopenjdk-11-openj9xl - OpenJDK Development Kit 11 (JDK) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-11-openj9xl-jre - OpenJDK Runtime Environment 11 (JRE) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-12-hotspot - OpenJDK Development Kit 12 (JDK) by AdoptOpenJDK
adoptopenjdk-12-hotspot-jre - OpenJDK Runtime Environment 12 (JRE) by AdoptOpenJDK
adoptopenjdk-12-openj9 - OpenJDK Development Kit 12 (JDK) by AdoptOpenJDK
adoptopenjdk-12-openj9-jre - OpenJDK Runtime Environment 12 (JRE) by AdoptOpenJDK
adoptopenjdk-12-openj9xl - OpenJDK Development Kit 12 (JDK) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-12-openj9xl-jre - OpenJDK Runtime Environment 12 (JRE) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-13-hotspot - OpenJDK Development Kit 13 (JDK) with Hotspot by AdoptOpenJDK
adoptopenjdk-13-hotspot-jre - OpenJDK Runtime Environment 13 (JRE) with Hotspot by AdoptOpenJDK
adoptopenjdk-13-openj9 - OpenJDK Development Kit 13 (JDK) with Eclipse OpenJ9 by AdoptOpenJDK
adoptopenjdk-13-openj9-jre - OpenJDK Runtime Environment 13 (JRE) with Eclipse OpenJ9 by AdoptOpenJDK
adoptopenjdk-13-openj9xl - OpenJDK Development Kit 13 (JDK) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-13-openj9xl-jre - OpenJDK Runtime Environment 13 (JRE) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-14-hotspot - OpenJDK Development Kit 14 (JDK) with Hotspot by AdoptOpenJDK
adoptopenjdk-14-hotspot-jre - OpenJDK Runtime Environment 14 (JRE) with Hotspot by AdoptOpenJDK
adoptopenjdk-14-openj9 - OpenJDK Development Kit 14 (JDK) with Eclipse OpenJ9 by AdoptOpenJDK
adoptopenjdk-14-openj9-jre - OpenJDK Runtime Environment 14 (JRE) with Eclipse OpenJ9 by AdoptOpenJDK
adoptopenjdk-14-openj9xl - OpenJDK Development Kit 14 (JDK) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-14-openj9xl-jre - OpenJDK Runtime Environment 14 (JRE) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-8-hotspot - OpenJDK Development Kit 8 (JDK) with Hotspot by AdoptOpenJDK
adoptopenjdk-8-hotspot-jre - OpenJDK Runtime Environment 8 (JRE) with Hotspot by AdoptOpenJDK
adoptopenjdk-8-openj9 - OpenJDK Development Kit 8 (JDK) with Eclipse OpenJ9 by AdoptOpenJDK
adoptopenjdk-8-openj9-jre - OpenJDK Runtime Environment 8 (JRE) with Eclipse OpenJ9 by AdoptOpenJDK
adoptopenjdk-8-openj9xl - OpenJDK Development Kit 8 (JDK) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-8-openj9xl-jre - OpenJDK Runtime Environment 8 (JRE) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-15-hotspot - OpenJDK Development Kit 15 (JDK) with Hotspot by AdoptOpenJDK
adoptopenjdk-15-hotspot-jre - OpenJDK Runtime Environment 15 (JRE) with Hotspot by AdoptOpenJDK
adoptopenjdk-15-openj9 - OpenJDK Development Kit 15 (JDK) with Eclipse OpenJ9 by AdoptOpenJDK
adoptopenjdk-15-openj9-jre - OpenJDK Runtime Environment 15 (JRE) with Eclipse OpenJ9 by AdoptOpenJDK
adoptopenjdk-15-openj9xl - OpenJDK Development Kit 15 (JDK) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK
adoptopenjdk-15-openj9xl-jre - OpenJDK Runtime Environment 15 (JRE) with Eclipse OpenJ9 (Extra Large Heap) by AdoptOpenJDK

Install desired Java version.

$ sudo apt install adoptopenjdk-8-hotspot
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  adoptopenjdk-8-hotspot
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/103 MB of archives.
After this operation, 205 MB of additional disk space will be used.
Selecting previously unselected package adoptopenjdk-8-hotspot.
(Reading database ... 33674 files and directories currently installed.)
Preparing to unpack .../adoptopenjdk-8-hotspot_8u265-b01-3_amd64.deb ...
Unpacking adoptopenjdk-8-hotspot (8u265-b01-3) ...
Setting up adoptopenjdk-8-hotspot (8u265-b01-3) ...
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/appletviewer to provide /usr/bin/appletviewer (appletviewer) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/clhsdb to provide /usr/bin/clhsdb (clhsdb) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/extcheck to provide /usr/bin/extcheck (extcheck) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/hsdb to provide /usr/bin/hsdb (hsdb) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/idlj to provide /usr/bin/idlj (idlj) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jar to provide /usr/bin/jar (jar) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jarsigner to provide /usr/bin/jarsigner (jarsigner) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/javac to provide /usr/bin/javac (javac) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/javadoc to provide /usr/bin/javadoc (javadoc) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/javah to provide /usr/bin/javah (javah) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/javap to provide /usr/bin/javap (javap) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jcmd to provide /usr/bin/jcmd (jcmd) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jdb to provide /usr/bin/jdb (jdb) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jdeps to provide /usr/bin/jdeps (jdeps) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jfr to provide /usr/bin/jfr (jfr) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jhat to provide /usr/bin/jhat (jhat) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jinfo to provide /usr/bin/jinfo (jinfo) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jmap to provide /usr/bin/jmap (jmap) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jps to provide /usr/bin/jps (jps) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jrunscript to provide /usr/bin/jrunscript (jrunscript) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jsadebugd to provide /usr/bin/jsadebugd (jsadebugd) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jstack to provide /usr/bin/jstack (jstack) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jstat to provide /usr/bin/jstat (jstat) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/jstatd to provide /usr/bin/jstatd (jstatd) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/native2ascii to provide /usr/bin/native2ascii (native2ascii) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/rmic to provide /usr/bin/rmic (rmic) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/schemagen to provide /usr/bin/schemagen (schemagen) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/serialver to provide /usr/bin/serialver (serialver) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/wsgen to provide /usr/bin/wsgen (wsgen) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/wsimport to provide /usr/bin/wsimport (wsimport) in auto mode
update-alternatives: using /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/xjc to provide /usr/bin/xjc (xjc) in auto mode

Display Java version.

$ java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.265-b01, mixed mode)