AdoptOpenJDK のインストール

Mac mini 2018 が来たのでセットアップ

Homebrew

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


Homebrew version

$ brew --version
Homebrew 1.8.2
Homebrew/homebrew-core (git revision 4d0d; last commit 2018-11-08)
Homebrew/homebrew-cask (git revision 7fd8; last commit 2018-11-08)


adoptopenjdk

$ brew cask install adoptopenjdk


Java version

$ java -version
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment AdoptOpenJDK (build 11+28)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11+28, mixed mode)


古いバージョンのJDK

公式の cask は 11 のみのため、現在は tap してインストールする必要がある。

$ brew tap AdoptOpenJDK/openjdk
$ brew cask install adoptopenjdk8
$ brew cask install adoptopenjdk9


$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
    11, x86_64: "AdoptOpenJDK 11"   /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
    9, x86_64:  "AdoptOpenJDK 9"    /Library/Java/JavaVirtualMachines/adoptopenjdk-9.jdk/Contents/Home
    1.8.0_192, x86_64:  "AdoptOpenJDK 8"    /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

切り替え

$ export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_192`

その他のJDK

OpenJDK の場合

brew cask install java


Oracle JDKの場合(もうこんなもん使わないケド)

brew cask install oracle-jdk



今後はコレで決まりかな。

docs.aws.amazon.com

古いバージョンの Oracle JDK

$ brew tap caskroom/versions

こんな感じになっている。

$ brew cask info java8
java8: 1.8.0_192-b12,750e1c8617c5452694857ad95c3ee230
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Not installed
From: https://github.com/Homebrew/homebrew-cask-versions/blob/master/Casks/java8.rb
==> Name
Java Standard Edition Development Kit
==> Artifacts
JDK 8 Update 192.pkg (Pkg)
==> 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.

Installing java8 means you have AGREED to the license at
  https://www.oracle.com/technetwork/java/javase/terms/license/index.html

インストール

$ brew cask install java8