Builds failing after upgrading to Java7, Missing Tools.jar and bad class versions

后端 未结 8 1747
滥情空心
滥情空心 2020-12-08 17:55

I recently upgraded to Java7 on my Macbook Pro. I downloaded the JDK (not the JRE).

» javac version
javac 1.7.0_17

» echo $JAVA_HOME    
/Library/Java/Java         


        
8条回答
  •  执笔经年
    2020-12-08 18:27

    The correct way to set JAVA_HOME on MacOS X is to use:

    [user@ip ~]$ export JAVA_HOME=$(/usr/libexec/java_home -v1.7)
    [user@ip ~]$ echo $JAVA_HOME 
    /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home
    

    Your java installation is broken if, after doing this, $JAVA_HOME/lib does not contain a tools.jar.

    Tip: I have these two aliases specified in my ~/.bash_profile:

    alias java6="export JAVA_HOME=$(/usr/libexec/java_home -v1.6)"  
    alias java7="export JAVA_HOME=$(/usr/libexec/java_home -v1.7)"
    

    Placing jars in /Library/Java/Extensions is equivalent to putting them in the global classpath and is rarely a good idea.

提交回复
热议问题