• (转)在MAC上查找和设置$JAVA_HOME


    最近升级了MAC OS,装了JDK7 for mac,在这里下载JDK7 for mac,装完之后发现在默认的路径下找不到JDK7的HOME,如下所示:

    $ which java
    /usr/bin/java
    
    $ ls -l /usr/bin/java
    lrwxr-xr-x  1 root  wheel  74 Jan  4 20:24 /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   10 Jan  4 20:24 1.4 -> CurrentJDK
    lrwxr-xr-x  1 root  wheel   10 Jan  4 20:24 1.4.2 -> CurrentJDK
    lrwxr-xr-x  1 root  wheel   10 Jan  4 20:24 1.5 -> CurrentJDK
    lrwxr-xr-x  1 root  wheel   10 Jan  4 20:24 1.5.0 -> CurrentJDK
    lrwxr-xr-x  1 root  wheel   10 Jan  4 20:24 1.6 -> CurrentJDK
    lrwxr-xr-x  1 root  wheel   10 Jan  4 20:24 1.6.0 -> CurrentJDK
    drwxr-xr-x  7 root  wheel  238 Jan  4 20:25 A
    lrwxr-xr-x  1 root  wheel    1 Jan  4 20:24 Current -> A
    lrwxr-xr-x  1 root  wheel   59 Jan  4 20:24 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

    可是查看java的版本确实是1.7,如下:

    $ java -version
    java version "1.7.0_45"
    Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
    Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

    google了一下,发现了这篇文章Important Java Directories on Mac OS X,可以使用工具命令“/usr/libexec/java_home”来定位JAVA_HOME,这下爽了:

    $ cat ~/.profile
    
    JAVA_HOME=`/usr/libexec/java_home`
    export JAVA_HOME
    
    $ echo $JAVA_HOME
    /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home

    另外可以使用-V选项列出所有版本的JAVA_HOME:

    $ /usr/libexec/java_home -V
    Matching Java Virtual Machines (3):
        1.7.0_45, x86_64:    "Java SE 7"    /Library/Java/JavaVirtualMachines/jdk1.7.0_45.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
    
    /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home

    原文地址:http://guibin.iteye.com/blog/1999238

  • 相关阅读:
    Hibernate 工作原理及为什么要用
    一款很好用的JQuery dtree树状图插件(一)
    android PopupWindow
    android 截屏工具类
    ubuntu 中文输入法
    Google GCM推送
    windows 安装配置 ant
    (转)Angular中的拦截器Interceptor
    flex 布局 自己做的demo
    flex布局 (转)
  • 原文地址:https://www.cnblogs.com/albert1017/p/4739594.html
Copyright © 2020-2023  润新知