Tuesday, January 15, 2013

Install JDK 7 and update-alternatives on Ubuntu 12.10

Download update JDK here: http://www.oracle.com/technetwork/java/javase/downloads/index.html, click the DOWNLOAD Java Platform graph.




Scroll download to check the box of Accept License Agreement, and select the package to download. In this case, jdk-7u11-linux-i586.tar.gz for Linux x86 is selected.


Move the downloaded .tar.gz archive binary to the directory you want to install.

Open a Terminal, the the command to unpack the tarball and install the JDK:
$tar zxvf jdk-7u11-linux-i586.tar.gz

For example, if you download the .tar.gz is /home/you, your installed directory will be /home/you/jdk1.7.0_11.

Then, you have to update alternatives for javac and java:
$sudo update-alternatives --install /usr/bin/javac javac /home/you/jdk1.7.0_11/bin/javac 1
$sudo update-alternatives --install /usr/bin/java java /home/you/jdk1.7.0_11/bin/java 1

If you have more than one javac installed, you have to config your javac alternative
$sudo update-alternatives --config javac
$sudo update-alternatives --config java

Finally, delete the downloaded .tar.gz after then.


No comments:

Post a Comment