Use update-alternatives to switch the default java commands in ubuntu
Sky @ sky-VGN-CR23-B :~ $ Cd/usr/java/jdk1.7.0 _ 21/
Sky @ sky-VGN-CR23-B:/usr/java/jdk1.7.0 _ 21 $ cd ..
Sky @ sky-VGN-CR23-B:/usr/java $ sudo ln-s./jdk1.7.0 _ 21./jdk1.7
Sky @ sky-VGN-CR23-B:/usr/java $ sudo rm jdk-7u21-linux-i586.tar.gz.
Sky @ sky-VGN-CR23-B:/usr/java $ sudo update-alternatives -- install/usr/bin/java/usr/java/jdk1.7/bin/java 1
Update-alternatives: using/usr/java/jdk1.7/bin/java to provide/usr/bin/java (java) in automatic mode
Sky @ sky-VGN-CR23-B:/usr/java $ sudo update-alternatives -- config java
There is only one alternative in link group java (providing/usr/bin/java):/usr/java/jdk1.7/bin/java
No configuration is required.
Sky @ sky-VGN-CR23-B:/usr/java $ java-version
Java version "1.7.0 _ 21"
Java (TM) SE Runtime Environment (build 1.7.0 _ 21-b11)
Java HotSpot (TM) Server VM (build 23.21-b01, mixed mode)
Sky @ sky-VGN-CR23-B:/usr/java $ ll/usr/bin/java
Lrwxrwxrwx 1 root 22 April 27 01:23/usr/bin/java->/etc/alternatives/java *
Sky @ sky-VGN-CR23-B:/usr/java $ ll/etc/alternatives/java
Lrwxrwxrwx 1 root 25 April 27 01:23/etc/alternatives/java->/usr/java/jdk1.7/bin/java *
Sky @ sky-VGN-CR23-B:/usr/java $ ll/usr/java/jdk1.7
Lrwxrwxrwx 1 root 13 01:14/usr/java/jdk1.7->./jdk1.7.0 _ 21/