# if you have already install some other version of JDK, please export the JAVA_HOME env before your android build every time $ sudo update-alternatives -install /usr/bin/jar jar /opt/java/64/jdk1.6.0_45/bin/jar 1 $ sudo update-alternatives -install /usr/bin/javac javac /opt/java/64/jdk1.6.0_45/bin/javac 1 $ sudo update-alternatives -install /usr/bin/java java /opt/java/64/jdk1.6.0_45/bin/java 1 $ wget -no-cookies -header "Cookie: gpw_e24=http%3A%2F%2F There are below options to help install the Sun's JDK if you cannot find a valid source through apt-get commands:
$ sudo apt - get install sun - java6 - jdk
$ sudo add - apt - repository "deb lucid partner" You may still cannot get the Sun's JDK with below instruction: To build Android version earlier than Lollipop from source code, you need the Sun's 1.6 SDK to be installed for ubuntu as the link Initializing a Build Environment | Android Developers.