MacOS java多版本安装与管理-sdkman

时间:2024-11-12 07:18:23

安装sdkman

curl -s "https://get.sdkman.io" | bash

image.png

source "$HOME/.sdkman/bin/sdkman-init.sh"

sdk version

image.png

正常出现sdkman版本号就安装成功了

# 安装java

# 安装java8

sdk install java 8.0.412.fx-zulu

image.png

建议和上述一样安装 fx-zulu 的jdk,这样会自带JAVAFX,方便后续使用java工具

ln -s ~/.sdkman/candidates/java/8.0.412.fx-zulu ~/.sdkman/candidates/java/8

sdk use java 8

java -version

image.png

# 安装jdk11

sdk install java 11.0.23.fx-zulu

image.png

ln -s ~/.sdkman/candidates/java/11.0.23.fx-zulu ~/.sdkman/candidates/java/11

sdk use java 11

java -version

image.png

# 安装jdk22

sdk install java 22.0.1.fx-zulu

image.png

ln -s ~/.sdkman/candidates/java/22.0.1.fx-zulu ~/.sdkman/candidates/java/22 

sdk use java 22                                                            

java -version

image.png

# 版本切换

切换java8

sdk use java 8

java -version 

切换java11

sdk use java 11

java -version 

切换java22

sdk use java 22

java -version 

image.png