今のJavaインストール状態の確認
$ /usr/libexec/java_home -V Matching Java Virtual Machines (4): 1.8.0_31, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home 1.7.0_71, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home 1.6.0_65-b14-466.1, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home 1.6.0_65-b14-466.1, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home
Java8のアンインストール方法
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
JDK8のアンインストール方法
sudo rm -fr /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk
状況を確認してみます。
$ /usr/libexec/java_home -V Matching Java Virtual Machines (3): 1.7.0_71, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home 1.6.0_65-b14-466.1, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home 1.6.0_65-b14-466.1, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
HomebrewでJava8をインストール
brew cask install java
状況を確認してみます。
$ /usr/libexec/java_home -V Matching Java Virtual Machines (4): 1.8.0_40, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home 1.7.0_71, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home 1.6.0_65-b14-466.1, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home 1.6.0_65-b14-466.1, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
Java8のリンク先を確認します。
$ /usr/libexec/java_home -v "1.8" /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
~/.bash_profile を書き換えます。
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home PATH=${JAVA_HOME}/bin:${PATH}:${PLAY_HOME}
反映します。
source ~/.bash_profile
バージョンを確認してみます。
$ java -version java version "1.8.0_40" Java(TM) SE Runtime Environment (build 1.8.0_40-b25) Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
$ javac -version javac 1.8.0_40
参考
http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html
https://www.java.com/ja/download/help/mac_uninstall_java.xml
http://nanananande.helpfulness.jp/post-3553/
http://qiita.com/keneo/items/0a58b188183b5100e3af