除了可以用AdoptOpenJDK 安装JDK外,还可以使用SDKMAN来安装JDK和管理多个JDK版本。
# install sdkman
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
# verify sdkman version
sdk version
# list avaible java version
# note the Identifier
sdk list java
# install java (laest stable)
sdk install java
# install specific java version
# java 8 from AdoptOpenJDK
# 8.0.292.j9 | adpt | | 8.0.292.j9-adpt
sdk install java 8.0.292.j9-adpt
# java 11 from AdoptOpenJDK
# 11.0.11.j9 | adpt | | 11.0.11.j9-adpt
sdk install java 11.0.11.j9-adpt
# list avaible java version
# note the Status: installed
# note the Use: >>> means current version
sdk list java
# set default java version
sdk default java 8.0.292.j9-adpt
# check current java version
sdk current java
# use version
sdk use java 11.0.11.j9-adpt
# check java version
java --version
SDKMAN 除了可以安装JDK外还可以安装其他SDK,参见:
SDKMAN 安装时下载安装包可能会非常慢,比如从GitHub上下载安装包取决于你本地和GitHub的网络状况。
可以先下载对应的安装包,再手工复制到~/.sdkman.tmp
目录,并重命名为<Identifier>.bin
,再运行sdk install <sdk> <Identifier>
来安装。
参见:
参考文档: