最新のJDKのインストール
Homebrew-caskでインストールしていきます。
まずはbrewのupdateから
$ brew update
Homebrew-caskのJDKバージョンを確認
$ brew cask info java
java: 1.8.0_45
Java, Java Standard Edition Development Kit
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Not installed
https://github.com/caskroom/homebrew-cask/blob/master/Casks/java.rb
==> Contents
JDK 8 Update 45.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 this Cask means you have AGREED to the Oracle Binary Code
License Agreement for Java SE at
http://www.oracle.com/technetwork/java/javase/terms/license/index.html
Homebrew-caskでインストール
$ brew cask install java
JDKのバージョンの切替
$ export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_45`
JDKのバージョンの確認
$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
インストールされているJDKのバージョンを確認
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
1.8.0_45, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
1.7.0_75, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
1.6.0_65-b14-462, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_65-b14-462, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home