Mac installation Java configuration Java_home

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.