Configure Java_home under Mac

Source: Internet
Author: User

http://blog.csdn.net/shallowgrave/article/details/39367119


Nothing to do, install a hbase to play, suddenly found that the default installation of Mac JDK7, no configuration java_home not so on their own with Bai.

Open the notes for configuring your Java environment when you configured your Hadoop cluster, and find the step to add an environment variable:

[Plain]View Plaincopyprint?
    1. Export Java_home=/usr/java/latest
    2. Export classpath=.: $JAVA _home
    3. Export path= $PATH: $JAVA _home/bin: $JAVA _home/jre/binexport classpath=.: $JAVA _home/lib: $CLASSPATH


Before it was configured in the Linux environment, switching to another UNIX-like system is now a similar scenario. Just find the actual installation path to the JDK.

Just before the JDK dependency in the configuration maven relies a bit like experience.

[Plain]View Plaincopyprint?
    1. Shuchen-2:bin seishuchen$ which Java
    2. /usr/bin/java
    3. Shuchen-2:bin seishuchen$ Ls-la/usr/bin/java
    4. Lrwxr-xr-x 1 root Wheel 4-2014/usr/bin/java-/system/library/frameworks/javavm.framework/versions/curren T/commands/java
    5. Shuchen-2:bin seishuchen$

The real path to the current JDK is quickly found. View path name discovery, there is a versions field and the current field, as a program ape, this is sensitive or some.

Immediately switch to the versions directory below to view:

[Plain]View Plaincopyprint?
  1. Shuchen-2:versions seishuchen$ cd/system/library/frameworks/javavm.framework/versions
  2. Shuchen-2:versions seishuchen$ Ls-al
  3. Total 72
  4. Drwxr-xr-x root Wheel 408 Jul 15 17:13.
  5. Drwxr-xr-x root Wheel 408 Apr 11 15:10..
  6. Lrwxr-xr-x 1 root Wheel 4 1.4-CURRENTJDK
  7. Lrwxr-xr-x 1 root Wheel 4 1.4.2-CURRENTJDK
  8. Lrwxr-xr-x 1 root Wheel 4 1.5-CURRENTJDK
  9. Lrwxr-xr-x 1 root Wheel 4 1.5.0-CURRENTJDK
  10. Lrwxr-xr-x 1 Root Wheel 4 1.6-CURRENTJDK
  11. Lrwxr-xr-x 1 root Wheel 4 1.6.0-CURRENTJDK
  12. Drwxr-xr-x 8 root Wheel 272 Mar 4 A
  13. Lrwxr-xr-x 1 root Wheel 1 Mar 4 Current-A
  14. Lrwxr-xr-x 1 root wheel 17:12 currentjdk-/library/java/javavirtualmachines/jdk1.7.0_51.jdk/contents
  15. Lrwxr-xr-x 1 root Wheel 4 Currentjdk_bak-/system/library/java/javavirtualmachines/1.6.0.jdk/conte Nts

The result is obvious, there is wood, originally all pointed to the/library/java/javavirtualmachines/jdk1.7.0_51.jdk/contents

Then switch to the past and look at it.

[Plain]View Plaincopyprint?
  1. Shuchen-2:versions seishuchen$ cd/library/java/javavirtualmachines/jdk1.7.0_51.jdk/contents
  2. Shuchen-2:contents seishuchen$ ls
  3. Home Info.plist MacOS
  4. Shuchen-2:contents seishuchen$ CD home/
  5. Shuchen-2:home seishuchen$ ls
  6. COPYRIGHT bin Man
  7. LICENSE DB Release
  8. Readme.html include Src.zip
  9. Thirdpartylicensereadme-javafx.txt JRE
  10. THIRDPARTYLICENSEREADME.txt Lib
  11. Shuchen-2:home seishuchen$

See the long-lost JDK installation directory is not. Well, our java_home is/library/java/javavirtualmachines/jdk1.7.0_51.jdk/contents/home.

The process looks very complicated, of course, this is for a most primitive method, if you are familiar with the Mac, actually have a java_home to get a small tool, directly on the command line

Enter/usr/libexec/java_home to get.

[Plain]View Plaincopyprint?
    1. Shuchen-2:home seishuchen$/usr/libexec/java_home
    2. /library/java/javavirtualmachines/jdk1.7.0_51.jdk/contents/home
    3. Shuchen-2:home seishuchen$

Then just modify the configuration file to make it effective. Depending on your needs, you can choose to modify the different environment variable profiles.

And I just modify the current user can. As long as the ~/.profile (Mac can also edit ~/.BASHRC, but ~/.bash_profile is not sure, interested can own beforehand)

Join:

[Plain]View Plaincopyprint?
    1. Java_home= '/usr/libexec/java_home '
    2. Export Java_home
    3. Export classpath=.: $JAVA _home
    4. Export path= $PATH: $JAVA _home/bin: $JAVA _home/jre/bin
    5. Export classpath=.: $JAVA _home/lib: $CLASSPATH

Then source ~/.profile, OK, call it off.

Execute hbase startup script, use JPS to look at the situation, find everything is so perfect, oh haha

Configure Java_home under Mac

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.