Pre-Requisite:
我已经在我的机器上使用brew安装了java11。
步骤1:酿造信息java11
输出:
/选择/自制/酒窖/openjdk@11
USER1-MacBook-Pro JavaVirtualMachines % brew info java11
openjdk@11: stable 11.0.12 (bottled) [keg-only]
Development kit for the Java programming language
https://openjdk.java.net/
/opt/homebrew/Cellar/openjdk@11/11.0.12 (670 files, 273.0MB)
Poured from bottle on 2021-10-09 at 13:07:04
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openjdk@11.rb
License: GPL-2.0-only
==> Dependencies
Build: autoconf ✔
==> Requirements
Build: Xcode ✘
==> Caveats
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"
==> Analytics
install: 44,188 (30 days), 149,578 (90 days), 433,845 (365 days)
install-on-request: 19,074 (30 days), 63,262 (90 days), 187,286 (365 days)
build-error: 0 (30 days)
步骤2:将openJDK路径附加到现有路径。
echo 'export PATH="/opt/homebrew/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc . bin:$PATH
步骤3:源现有shell或打开新终端以验证更改
来源 ~/.zshrc
步骤4:添加检查路径
而java
输出:/ opt /自制/ opt / openjdk@11 / bin / java
步骤5:
java——版本
openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment Homebrew (build 11.0.12+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)