How to change default JAVA of linux to lastet version

How to change default JAVA of linux to lastet version:
—————————————————————-

First check all the executables as mentioned below:

cd /usr/bin
ls -l |grep ja

lrwxrwxrwx 1 root root           25 Jul 31 11:33 jar -> /usr/java/default/bin/jar
lrwxrwxrwx 1 root root           34 Jul 31 12:00 java -> /usr/java/java-1.4/jre/bin/java
lrwxrwxrwx 1 root root           27 Jul 31 11:33 javac -> /usr/java/default/bin/javac
lrwxrwxrwx 1 root root           29 Jul 31 11:33 javadoc -> /usr/java/default/bin/javadoc
lrwxrwxrwx 1 root root           28 Jul 31 11:33 javaws -> /usr/java/default/bin/javaws
lrwxrwxrwx 1 root root           30 Jul 31 11:33 jcontrol -> /usr/java/default/bin/jcontrol

So here you can see all the java components are pointing to /usr/java/default but the “java” component is pointing to java-1.4 :

ls -l /usr/java/default
/usr/java/default ->  /usr/java/jdk1.6.0_26

So, all the components are pointing to the latest version of JDK installed except : java

So when I check : which java
/usr/bin/java
java -version
java 1.4

So , I have to change the “java” executable to point to the latest version that is java-1.6_26 which is installed at location: /usr/java/jdk1.6.0_26

mv /usr/bin/java /usr/bin/java1.4
ln -s /usr/java/jdk1.6.0_26/jre/bin/java /usr/bin/java

Now check :
cd /usr/bin
ls -l |grep ja
lrwxrwxrwx 1 root root           25 Jul 31 11:33 jar -> /usr/java/default/bin/jar
lrwxrwxrwx 1 root root           34 Jul 31 12:00 java -> /usr/java/jdk1.6.0_26/jre/bin/java
lrwxrwxrwx 1 root root           22 Jun 20 15:39 java1.4 -> /usr/java/java-1.4/jre/bin/java
lrwxrwxrwx 1 root root           27 Jul 31 11:33 javac -> /usr/java/default/bin/javac
lrwxrwxrwx 1 root root           29 Jul 31 11:33 javadoc -> /usr/java/default/bin/javadoc
lrwxrwxrwx 1 root root           28 Jul 31 11:33 javaws -> /usr/java/default/bin/javaws
lrwxrwxrwx 1 root root           30 Jul 31 11:33 jcontrol -> /usr/java/default/bin/jcontrol

Please follow and like us:

One Response

  1. Doug P. May 16, 2013

Please add your comments here