2013年10月18日 星期五

Ubuntu 12.04 Install JDK 6 for Android Source Code Builde

Install the Oracle JDK 6

http://askubuntu.com/questions/67909/how-do-i-install-oracles-jdk-6
Oracle themselves have the official guide to install their JDK - below is based upon those instructions.
  • Download the 32bit or 64bit Linux "compressed binary file" - it has a ".bin" file extension
  • Give it permissions to execute and extract it
    chmod a+x [version]-linux-i586.bin
    ./[version]-linux-i586.bin
During installation it will ask you to register - press ENTER. Firefox will open with the registration page. Registration is optional.
JDK 6 package is extracted into ./jdk1.6.0_x directory, for example ./jdk1.6.0_30.
Lets rename it:

JDK 6 
https://app.box.com/s/uar3raw5qh1w46bqnnnq

mv jdk1.6.0_30 java-6-oracle 
  • Now move the JDK 6 directory to /usr/lib
sudo mkdir /usr/lib/jvm
sudo mv java-6-oracle /usr/lib/jvm

switch to Oracle JDK 6

download

https://app.box.com/s/uuaac6svwnmn4bx2qwki

webupd8.googlecode.com hosts a nice-easy script to help with this.
wget http://webupd8.googlecode.com/files/update-java-0.5b chmod +x update-java-0.5b sudo ./update-java-0.5b 
don't worry - 0.5b refers to the script version - not the version of java!
An alternative to this is to use the webupd8 ppa and the update-java package.
enter image description here
Finally test the switch has been successful:
java -version javac -version 
These should display the oracle version installed - 1.6.0_30

Ubuntu GNU/Linux 12.04 LTS (Precise Pangolin) released. I wanted to manually install the Sun JDK 6 and 7 on Ubuntu.
Installing Sun JDK 6 on Ubuntu 12.04:
  • Make the bin file executeable:
chmod +x jdk-6u32-linux-x64.bin
  • Extract the bin file:
./jdk-6u32-linux-x64.bin
  • Move extracted folder to this location:
sudo mv jdk1.6.0_32 /usr/lib/jvm/
  • Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_32/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_32/bin/java 1
  • Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
  • java version test:
java -version

----------------------------------
Installing Sun JDK 7 on Ubuntu 12.04:
  • Download the sun jdk 7 tar file from here
  • Extract the tar file:
tar -xvzf jdk-7u4-linux-x64.tar.gz
  • Move extracted folder to this location:
sudo mv jdk1.7.0_04 /usr/lib/jvm/
  • Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_04/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_04/bin/java 1
  • Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
  • java version test:
java -version