My current java version running on my Ubuntu 14.04 is
java -version
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
I've typed the command to change the java version
sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
* 1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1 manual mode
Press enter to keep the current choice[*], or type selection number: 1
test@test-ZX-530:/media/test/SSD/N7$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1071 auto mode
* 1 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1071 manual mode
2 /usr/lib/jvm/java-7-oracle/bin/javac 1 manual mode
Press enter to keep the current choice[*], or type selection number: 1
After configuring this, the java -version does not change.
When I tried to build Android 5.0, the error occured and shown the following error message:
============================================
Checking build tools versions...
************************************************************
You asked for an OpenJDK 7 build but your version is
java version "1.7.0_72" Java(TM) SE Runtime Environment (build 1.7.0_72-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode).
************************************************************
build/core/main.mk:191: *** stop. Stop.
#### make failed to build some targets ####
Any idea to this? Thanks!
==================================================================================
I have found out the question to this issue.
The java version is Openjdk when I run
. build/envsetup.sh
However, when I run
lunch aosp_flo-userdebug
The java version switch back to Java SE.
Please let me know if you may have any idea
Thanks
===========================================================================
Hi,
lunch aosp_flo-userdebug
I thihk this command checks my configuration and switches back to Java SE jdk version.
After running this command and exporting my OpenJDK path again make the build work.
Building Kitkat needs Sun/Oracle JDK 6 version, and building Lollipop needs OpenJDK 7. Currently, I have both projects on my Ubuntu. I use a script to switch the JDK version, and it works.
Put the jdk_switch.sh in my ~ directory and run the following commands to switch jdk version:
$ . ./jdk_switch.sh jdk7
$ . ./jdk_switch.sh jdk6
The path of JDK are:
/usr/lib/jvm/java-6-oracle/
/usr/lib/jvm/java-7-openjdk-amd64/
The content of jdk_switch.sh:
#!/bin/bash
case $1 in
jdk6)
export JAVA_HOME=/usr/lib/jvm/java-6-oracle/
;;
jdk7)
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
;;
*)
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
;;
esac
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
java -version
OpenJDK 7 version is :
java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.12.04.1)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
In your case, exporting your PATH and CLASSPATH might helpful. Or just use a simple bash script. I hope this might help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With