1

I am compiling android system source and come across a problem.

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

I open terminal to try to see my java version.

1, When I input /usr/libexec/java_home and it tells me 1.8

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

2, When I input java -version and it tells me 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, I write the below line in .profile to try to switch JDK version.

# 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, I run source .profile and run 'jdk6' and run 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, But when I input /usr/libexec/java_home and it still tells me 1.8

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

6, And my problem still exists.It tell me My mac still use JDK 1.8 instead of 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

Question 1:

How can I switch JDK version in my mac? Is the way I use correct?

Question 2:

Why does "/usr/libexec/java_home" not change?

QuinnChen
  • 670
  • 1
  • 8
  • 29
  • http://stackoverflow.com/questions/21964709/how-to-set-or-change-the-default-java-jdk-version-on-os-x , If you try this and still doesn't work, Just uninstall the JDK temporarily, which should be 1.8 – Tosin Onikute Sep 16 '15 at 02:45

0 Answers0