本文最后更新于 1724 天前,其中的信息可能已经有所发展或是发生改变。
2020-04-02更新:
之前的安装方法已经废弃了,可通过以下方式安装
brew tap AdoptOpenJDK/openjdk brew cask install <version>
这里有全部的version列表
例如可以这么安装
brew cask install adoptopenjdk8
之前用brew安装了java9。但我有些软件不兼容,只能降级到java8。这里简单记录下步骤。
卸载
brew cask uninstall java
安装指定版本
brew tap caskroom/versions
foam@foamdeMBP: sens » brew cask search java [15:13:54] ==> Exact Match java ==> Partial Matches charles-applejava eclipse-javascript java6 netbeans-java-ee yourkit-java-profiler eclipse-java java-jdk-javadoc java8 netbeans-java-se
估计我没更新brew的缘故,上面只列出java6和java8。java7呢,有点懵逼。
键入下面命令,然后就会自动下载安装了。可能会有点慢,挂个代理或VPN好些。
foam@foamdeMBP: sens » brew cask install java8 Updating Homebrew... ^CWarning: Unexpected method 'license' called during caveats on Cask java8. Follow the instructions here: https://github.com/caskroom/homebrew-cask#reporting-bugs ==> Caveats This Cask makes minor modifications to the JRE to prevent issues with packaged applications, as discussed here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361 If your Java application still asks for JRE installation, you might need to reboot or logout/login. ==> Satisfying dependencies ==> Downloading http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/jdk-8u172-macosx-x64.dmg ######################################################################## 100.0% ==> Verifying checksum for Cask java8 ==> Installing Cask java8 ==> Running installer for java8; your password may be necessary. ==> Package installers may write to any location; options such as --appdir are ignored. Password: ==> installer: Package name is JDK 8 Update 172 ==> installer: Installing at base path / ==> installer: The install was successful. 🍺 java8 was successfully installed!
确认下,ok了。
foam@foamdeMBP: sens » java -version [15:46:05] java version "1.8.0_172" Java(TM) SE Runtime Environment (build 1.8.0_172-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)