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
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"
Set jdk for jenv
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
$ where java /opt/homebrew/opt/openjdk@11/bin/java /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
$ jenv versions openjdk64-11.0.11
$ jenv add /opt/homebrew/opt/openjdk@11
$ jenv versions * openjdk64-11.0.11 (set by /Users/yuanli/.jenv/version) openjdk64-11.0.15
# set default jdk version $ jenv global openjdk64-11.0.15
$ jenv versions openjdk64-11.0.11 * openjdk64-11.0.15 (set by /Users/yuanli/.jenv/version)
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