切换Mac JAVA_HOME失败

时间:2015-09-16 02:39:29

标签: java android macos

我正在编译android系统源并遇到问题。

You are attempting to build with the incorrect version of java.

Your version is: java version "1.8.0_45".
The correct version is: Java SE 1.6.

Please follow the machine setup instructions at
https://source.android.com/source/download.html

我打开终端试图查看我的java版本。

1,当我输入/ usr / libexec / java_home并告诉我1.8

QuinnChens-MacBook-Pro:Android4.4 Quinn$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

2,当我输入java -version并告诉我1.8

QuinnChens-MacBook-Pro:Android4.4 Quinn$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

3,我在.profile中编写以下行以尝试切换JDK版本。

# Mac  JDK 6 
export JAVA_6_HOME=$(/usr/libexec/java_home -v 1.6 )

# Mac  JDK 8
export JAVA_8_HOME=$(/usr/libexec/java_home -v 1.8 )

#alias dymatically switch  JDK 
alias jdk6="export JAVA_HOME=$JAVA_6_HOME"
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"

4,我运行源.profile并运行' jdk6'并运行java -version

QuinnChens-MacBook-Pro:Android4.4 Quinn$ source ~/.profile
QuinnChens-MacBook-Pro:Android4.4 Quinn$ jdk6
QuinnChens-MacBook-Pro:Android4.4 Quinn$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

5,但是当我输入/ usr / libexec / java_home并且仍然告诉我1.8

QuinnChens-MacBook-Pro:Android4.4 Quinn$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

6,我的问题仍然存在。它告诉我我的mac仍然使用JDK 1.8而不是1.6

You are attempting to build with the incorrect version of java.

Your version is: java version "1.8.0_45".
The correct version is: Java SE 1.6.

Please follow the machine setup instructions at
https://source.android.com/source/download.html

问题1:

如何在Mac中切换JDK版本?我使用的方式是否正确?

问题2:

为什么" / usr / libexec / java_home"不改变?

0 个答案:

没有答案