首先请安装依赖:
sudo apt-get update && sudo apt-get install -y wget apt-transport-https
然后信任 GPG 公钥:
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /etc/apt/keyrings/adoptium.asc
随后执行以下命令来添加 apt 存储库:
echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
再执行
sudo apt-get update
apt-get install temurin-8-jdk
之后可以使用 apt-get install temurin-
安装软件包,例如 temurin-17-jdk
和 temurin-8-jdk
。
JAVA_HOME配置
export JAVA_HOME=/usr/lib/jvm/temurin-8-jdk-amd64
export PATH=$PATH:$JAVA_HOME/bin