3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

mac上にhomebrewでAdoptOpenJDK11をインストール

Posted at

インストール方法

2019/5/29現在、以下のコマンドを実行するとAdoptOpenJDK12がインストールされます。

brew cask install adoptopenjdk

LTS版を使用したいときなど、バージョンを指定して入れるにはどうすればいいかというのは、infoを出してみると表示されます。

brew cask info adoptopenjdk
adoptopenjdk: 12.0.1,12
https://adoptopenjdk.net/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/adoptopenjdk.rb
==> Name
AdoptOpenJDK Java Development Kit
==> Artifacts
jdk-12.0.1+12 -> /Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk (Generic Artifact)
==> Caveats
More versions are available in the AdoptOpenJDK tap:
  https://github.com/AdoptOpenJDK/homebrew-openjdk

  brew tap adoptopenjdk/openjdk

というわけで、adoptopenjdk/openjdkをtapすればいいらしい。

brew tap adoptopenjdk/openjdk

これを実行後に検索してみると各バージョンが見えるようになりました。

brew search adoptopenjdk
==> Casks
adoptopenjdk                             adoptopenjdk12-openj9-jre
adoptopenjdk10                           adoptopenjdk8
adoptopenjdk11                           adoptopenjdk8
adoptopenjdk11-jre                       adoptopenjdk8-jre
adoptopenjdk11-openj9                    adoptopenjdk8-openj9
adoptopenjdk11-openj9-jre                adoptopenjdk8-openj9-jre
adoptopenjdk12                           adoptopenjdk8-openj9-large
adoptopenjdk12-jre                       adoptopenjdk9
adoptopenjdk12-openj9

無印がHotspot JVM版、openj9と付いているのが OpenJ9 JVM版のようです。
今回はAdoptOpenJDK11の、せっかくなのでOpenJ9版を入れてみることにします。

brew cask install adoptopenjdk11-openj9
Updating Homebrew...
(略)

==> Satisfying dependencies
==> Downloading https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/1404190
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'adoptopenjdk11-openj9'.
==> Installing Cask adoptopenjdk11-openj9
==> Running installer for adoptopenjdk11-openj9; 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.
🍺  adoptopenjdk11-openj9 was successfully installed!

インストール確認

/usr/libexec/java_home -v 11
/Library/Java/JavaVirtualMachines/adoptopenjdk-11-openj9.jdk/Contents/Home

JAVA_HOME、PATHの設定

bashな人はこんな感じで設定してください。

export JAVA_HOME=`/usr/libexec/java_home -v 11`
PATH=$JAVA_HOME/bin:$PATH

筆者はfish使ってるのでこんな感じ

set -x JAVA_HOME (/usr/libexec/java_home -v 11)
set -x PATH $JAVA_HOME/bin $PATH

設定後、バージョン確認

java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.14.0, JRE 11 Mac OS X amd64-64-Bit Compressed References 20190418_204 (JIT enabled, AOT enabled)
OpenJ9   - bad1d4d06
OMR      - 4a4278e6
JCL      - 5cc996a803 based on jdk-11.0.3+7)

というわけで、問題なく設定できていそう。

参考

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?