macos 自带openjdk,但是版本较老,可以安装新的openjdk并保留原版,在shell的配置文件中导入新的openjdk环境变量即可。 在 http://openjdk.java.net/ 下载到新版本的压缩包 解压并移动到/usr/local/目录 在.zshrc(我用的是zsh)加入export PATH=/usr/local/jdk-17.0.1.jdk/Contents/Home/bin:$PATH 如下图:
/usr/local/
.zshrc
export PATH=/usr/local/jdk-17.0.1.jdk/Contents/Home/bin:$PATH