brew update # 老版本 brew tap caskroom/cask # 会报错: # Error: caskroom/cask was moved. Tap homebrew/cask instead. # 2021 新版本: brew tap homebrew/cask # 老版本: brew install brew-cask brew install homebrew/cask
安装brew-cask-completion:
1
brew install brew-cask-completion
But before doing that, let’s check if we already have JDK 7 installed by Homebrew Cask:
1 2 3 4 5
# 老版本 brew tap caskroom/versions # Error: caskroom/versions was moved. Tap homebrew/cask-versions instead. brew tap homebrew/cask-versions # 老版本:brew cask info java7 brew info --cask java7
==> openjdk@11 For the system Java wrappers to find this JDK, symlink it with sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
openjdk@11 is keg-only, which means it was not symlinked into /opt/homebrew, because this is an alternate version of another formula.
If you need to have openjdk@11 first in your PATH, run: echo'export PATH="/opt/homebrew/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc
For compilers to find openjdk@11 you may need to set: export CPPFLAGS="-I/opt/homebrew/opt/openjdk@11/include"
==> Pouring openjdk@17--17.0.16.arm64_sequoia.bottle.tar.gz ==> Caveats For the system Java wrappers to find this JDK, symlink it with sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk
openjdk@17 is keg-only, which means it was not symlinked into /opt/homebrew, because this is an alternate version of another formula.
If you need to have openjdk@17 first in your PATH, run: echo'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zshrc
For compilers to find openjdk@17 you may need to set: export CPPFLAGS="-I/opt/homebrew/opt/openjdk@17/include" ==> Summary 🍺 /opt/homebrew/Cellar/openjdk@17/17.0.16: 636 files, 305MB ==> Running `brew cleanup openjdk@17`... Disable this behaviour by setting `HOMEBREW_NO_INSTALL_CLEANUP=1`. Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
Add export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH" to ~/.zshrc
1 2 3 4 5 6 7 8 9
source ~/.zshrc
java -version # 应显示 openjdk 17.x.x openjdk version "17.0.16" 2025-07-15 OpenJDK Runtime Environment Homebrew (build 17.0.16+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.16+0, mixed mode, sharing)
To activate jenv, add the following to your shell profile e.g. ~/.profile, ~/.bash_profile or ~/.zshrc: export PATH="$HOME/.jenv/bin:$PATH" eval"$(jenv init -)" ==> Summary 🍺 /opt/homebrew/Cellar/jenv/0.5.9: 91 files, 100.9KB ==> Running `brew cleanup jenv`... Disable this behaviour by setting `HOMEBREW_NO_INSTALL_CLEANUP=1`. Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
jEnv doesn’t install JDKs, so we have to tell jEnv where to look for them. Type these commands to register JDKs in jEnv (replace the minor and patch versions with yours):
1 2 3 4
$ where java /usr/bin/java /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java