How to Set Java JDK Environment Variable for Mac OS X 10.8 Mountain Lion

前端 未结 3 747
醉酒成梦
醉酒成梦 2020-12-05 08:28

Can anybody tell me how to set environment variable for Mac OS X 10.8 Mountain Lion. I just upgrade my Mac to Mac OS X 10.8. When I run a script. It said that

\"/U

相关标签:
3条回答
  • 2020-12-05 08:58

    This is what I have tried:

    create the bash_profile:

    $ vim ~/.bash_profile 
    

    add this to the file:

    export JAVA_HOME=$(/usr/libexec/java_home)
    

    execute the source command

    $ source ~/.bash_profile
    

    echo JAVA_HOME:

    $ echo $JAVA_HOME
    /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
    
    0 讨论(0)
  • 2020-12-05 08:59

    I've found the following post very helpful -

    http://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/

    It explains how to set the path for a single user or system wide (OS X Leopard+)

    0 讨论(0)
  • 2020-12-05 09:07

    I created a file ~/.bash_profile and added:

    export PATH=/usr/local/mysql/bin:$PATH
    export PATH=/Users/sparkyspider/dev/javalibs/Grails/grails-2.1.1/bin:$PATH
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home
    

    And all's working great for me...

    0 讨论(0)
提交回复
热议问题