本文旨在MacOS big sur系统中,通过最新版本的homebrew 安装OpenJDK8.
因homebrew 对cask的规划变更至home-cask,如下的命令已经失效。
brew cask install AdoptOpenJDK。
Error: Unknown command: cask
可按照如下顺序进行安装,以下均为终端命令
1. homebrew 确保安装成功,并brew update最新。
2. brew tap AdoptOpenJDK/openjdk, 这个命令由于依旧是从国外的源更新,所以需要多试几次。
3. xcode-select --install。 确保最新os系统,安装使用最新的xcode command-line tools。
4. brew install adoptopenjdk8 或者 brew install --cask adoptopenjdk8
==> Downloading https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_mac_hotspot_8u292b1
==> Downloading from https://github-releases.githubusercontent.com/140418865/bbad4180-a2e0-11eb-8274-f16f6a90729c?X-Amz-Algorithm=AWS4
######################################################################## 100.0%
==> Installing Cask adoptopenjdk8
==> Running installer for adoptopenjdk8; your password may be necessary.
Package installers may write to any location; options such as `--appdir` are ignored.
Password:
installer: Package name is AdoptOpenJDK
installer: Installing at base path /
installer: The install was successful.
package-id: net.adoptopenjdk.8.jdk
version: 1.8.0_292-b10
volume: /
location:
install-time: 1619268356
🍺 adoptopenjdk8 was successfully installed!
5. 安装完成,使用java -version
java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)
6. 查看adoptopenjdk8 安装后的路径
brew info --cask adoptopenjdk8
返回信息中,下面这一行即是安装后的路径。
/usr/local/Caskroom/adoptopenjdk8/8,292:b10 (103.3MB)
brew info --cask adoptopenjdk8
adoptopenjdk8: 8,292:b10
https://adoptopenjdk.net/
/usr/local/Caskroom/adoptopenjdk8/8,292:b10 (103.3MB)
From: https://github.com/adoptopenjdk/homebrew-openjdk/blob/HEAD/Casks/adoptopenjdk8.rb
==> Name
AdoptOpenJDK 8
==> Description
AdoptOpenJDK OpenJDK (Java) Development Kit
==> Artifacts
OpenJDK8U-jdk_x64_mac_hotspot_8u292b10.pkg (Pkg)