我使用命令brew install openjdk@11
在我的mac上安装Java。但是当我运行java --version
时,我得到以下消息:
操作无法完成。无法定位Java运行时。
有关安装Java的信息,请访问http://www.java.com。我有几个问题:
- 如何使用HomeBrew安装JRE ?
- 我需要安装哪个版本的JRE ?
你的问题的答案可以通过运行:
brew info 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