由于安全问题,Debian在Buster版本已不再支持直接通过 apt-get 安装 openjdk-8-jdk 以及 openjdk-8-jre

1
2
3
4
5
Package openjdk-8-jdk-headless is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'openjdk-8-jdk-headless' has no installation candidate

这里通过2种方式来安装OpenJDK JDK/JRE 8。

SID源安装

以安装 openjdk-8-jdk 为例

1
2
3
echo "deb http://deb.debian.org/debian/ sid main" >> /etc/apt/sources.list

apt-get update && apt-get install -y openjdk-8-jdk

此方法简单粗暴,但会引用不稳定的deb安装包,请谨慎使用。

或安装完jdk/jre后直接删除sid源(卸磨杀驴.jpg)

AdoptOpenJDK安装

这里同样也采用deb包安装

安装所需依赖

apt-get update && apt-get install -y apt-transport-https software-properties-common ca-certificates lsb-release wget dirmngr gnupg

添加 AdoptOpenJDK GPG

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

添加 AdoptOpenJDK 官方仓库

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

若出现-bash: add-apt-repository: command not found 请检查是否成功安装所需依赖。

安装所需包

执行 apt-get update

1
2
3
4
5
#安装OpenJDK 8 JDK
apt-get install adoptopenjdk-8-hotspot

#安装OpenJDK 8 JRE
apt-get install adoptopenjdk-8-hotspot-jre

官方教程 https://adoptopenjdk.net/installation.html?variant=openjdk8&jvmVariant=hotspot#linux-pkg 参考自 https://stackoverflow.com/questions/57031649/how-to-install-openjdk-8-jdk-on-debian-10-buster