Bootstrap

mac安装java17

1、确保 Homebrew 已安装。如果没有安装,运行以下命令

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2、安装 OpenJDK 17

brew install openjdk@17

3、安装完成后,运行以下命令设置环境变量

echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

4、检查一下

java --version

看到这个就装好了

openjdk 17.0.13 2024-10-15
OpenJDK Runtime Environment Homebrew (build 17.0.13+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.13+0, mixed mode, sharing)
;