manually updating java in ubuntu

Below is outlined the process of updating to the latest JDK in ubuntu and updating the alternatives link manually to point the the latest java:

Step 1: Download:

wget http://download.oracle.com/otn-pub/java/jdk/7u15-b03/jdk-7u15-linux-x64.tar.gz
cd /usr/lib/jvm/
tar -xzf ~/downloads/jdk-7u15-linux-x64.tar.gz

Step 2: If java-7-sun already exists, the below is all that is needed if not skip to step 3 if this is the first time it is setup:

unlink java-7-sun
ln -s jdk1.7.0_15 java-7-sun

Step 3: If java-7-sun link does not already exists:

ln -s jdk1.7.0_15 java-7-sun
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-7-sun/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-7-sun/bin/javac" 1
update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/java-7-sun/jre/lib/amd64/libnpjp2.so" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/java-7-sun/bin/javaws" 1

Step 4: Choose the java just installed as default:

update-alternatives --config java
update-alternatives --config javac
update-alternatives --config javaws
update-alternatives --config mozilla-javaplugin.so

Comment