Wowza Community

After installing latest Java vesion, java command is still using old Java (fix)

Problem

After installing the latest version of the Java when I run the command java -version it still returns the version information for the prevoiusly installed version.

Solution

If you platform supports the alternatives mechanism, invoke it to select the new version of Java (enter /usr/sbin/alternatives --config java:

# /usr/sbin/alternatives --config java
There are 2 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
 + 1           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
*  2           /usr/java/jdk1.6.0_06/bin/java
Enter to keep the current selection[+], or type selection number: 2

This article describes the comamnds in more detail:

Linux: alternatives

If this does not work then you can just update the symbolic link at /usr/bin/java to point to the new version of Java. If the new version of Java is installed at /usr/java/jdk1.6.0_06, then execute the commands:

rm -rf /usr/bin/java
ln -sf /usr/java/jdk1.6.0_06/bin/java /usr/bin/java

Charlie

Problem

After installing the latest version of the Java when I run the command java -version it still returns the version information for the prevoiusly installed version.

Solution

If you platform supports the alternatives mechanism, invoke it to select the new version of Java (enter /usr/sbin/alternatives --config java:

I was having a similar problem in Ubuntu, where java -version showed

java version "1.5.0"
gij (GNU libgcj) version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)

For me the command to fix it was: sudo update-alternatives --config java. Just wanted to add that.

Use this command (executed by root) to enable alternative (on CentOS)

alternatives --install /usr/bin/java java /usr/java/latest/bin/java 2