Java Version – Fixing Installed Java Not Showing New Version on CentOS

centosjavapath

I just installed jdk1.6.0. I have tried multiple ways to set the path variable and make java 1.6 my new running version. And nothing is working. Running centos5 virtual machine.

alternatives –config java returns the following:

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.4.2-gcj/bin/java

java -version returns the following:

java version "1.4.2_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)
Java HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)

echo $PATH returns the following:

/root/bin:/opt/j2sdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/testing/jdk1.6.0_23/bin:/usr/local/testing/jdk1.6.0_23/bin

1.6.0 is installed in the following location: /usr/local/testing/jdk1.6.0_23/bin

Best Answer

I figured this out. I just appended the new java path to the beginning of my path variable instead of the end and it worked.

export PATH=/usr/local/testing/jdk1.6.0_23/bin:$PATH

That worked. Now i am going to set in my script so it will do automatically.

Related Question