在Debian 11上安装JDK 8

艰难的找到了这个页面 https://blog.adoptopenjdk.net/2019/05/adoptopenjdk-rpm-and-deb-files/

adoptopenjdk 是由社区维护的一个JDK版本,这里提供了包括jdk 8 到 jdk 11所有版本的Java 开发包。 以下是Debian 10 的安装方法

Debian/Ubuntu Instructions Import the official AdoptOpenJDK GPG key

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

Import the AdoptOpenJDK DEB repo using add-apt-repository. If you get a command not found error then try apt-get install -y software-properties-common first.

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

Install the AdoptOpenJDK version you require

1apt-get update # update if you haven't already
2apt-get install adoptopenjdk-8-hotspot

但是在Debian 11中会提示

1Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).

这是由于Debian 11之后不再支持apt-key这个指令了。如果你没注意的话会发现在更新软件列表时报出这样的错误:

1W: GPG error: https://adoptopenjdk.jfrog.io/adoptopenjdk/deb bullseye InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8AC3B29174885C03
2E: The repository 'https://adoptopenjdk.jfrog.io/adoptopenjdk/deb bullseye InRelease' is not signed.
3N: Updating from such a repository can't be done securely, and is therefore disabled by default.
4N: See apt-secure(8) manpage for repository creation and user configuration details.

解决起来也很简单,用如下的方法替代第一步即可

1wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/adoptopenjdk.gpg --import -
2sudo chown _apt /etc/apt/trusted.gpg.d/adoptopenjdk.gpg

之后再做apt udpate 就正常了

1apt update
2apt install adoptopenjdk-8-hotspot

现在可以愉快的使用Java 8了。

评论