1. Go to the Oracle website Java Download interface and find the JDK version you need to download. After clicking "Accept License Agreement", select your computer's download package (Mac OS X x64) and click the package to download it.
Jdk-8u66-macosx-x64.dmg
2. Configure Java_home
After loading, we find that JDK7 's home is not found under the default path, as shown below:
$ which Java
/usr/bin/java
$ ls-l/usr/bin/java
Lrwxr-xr-x 1 root Wheel 22:55/usr/bin/java-/system/library/frameworks/javavm.framework/versions/current /commands/java
$ ls-l/system/library/frameworks/javavm.framework/versions
Total 64
Lrwxr-xr-x 1 root wheel 22:55 1.4 Currentjdk
Lrwxr-xr-x 1 root wheel 22:55 1.4.2 currentjdk
Lrwxr-xr-x 1 root wheel 22:55 1.5 currentjdk
Lrwxr-xr-x 1 root wheel 22:55 1.5.0 currentjdk
Lrwxr-xr-x 1 root wheel 22:55 1.6 currentjdk
Lrwxr-xr-x 1 root wheel 22:55 1.6.0 currentjdk
Drwxr-xr-x 7 root wheel 238 22:55 A
Lrwxr-xr-x 1 root Wheel 1 22:55
Lrwxr-xr-x 1 root wheel 22:55 currentjdk-/library/java/javavirtualmachines/1.6.0.jdk/contents
Solve:
Google a bit, found this article important Java directories on Mac OS X, you can use the tool command "/usr/libexec/java_home" to locate Java_home
Vim ~/. Bash_profile
Join:
Java_home= '/usr/libexec/java_home '
Export Java_home
You can also use the-V option to list all versions of Java_home:
$/usr/libexec/java_home-v
Matching Java Virtual Machines (3):
1.8.0_66, x86_64: "Java SE 8" /library/java/javavirtualmachines/jdk1.8.0_66.jdk/contents/home
1.6.0_65-b14-468, x86_64: "Java SE 6" /library/java/javavirtualmachines/1.6.0.jdk/contents/home
1.6.0_65-b14-468, i386: "Java SE 6" /library/java/javavirtualmachines/1.6.0.jdk/contents/home
/library/java/javavirtualmachines/jdk1.8.0_66.jdk/contents/home
Finally, don't forget if. Bash_profile is just created and needs this sentence to make the configuration effective:
SOURCE . Bash_profile
Verify:
$ echo $JAVA _home
/library/java/javavirtualmachines/jdk1.8.0_66.jdk/contents/home
Mac installation Java configuration Java_home