views:

271

answers:

4

java -version still returns old java version. I have red hat linux

I installed jdk 1.5 int eh follwing path and updated the bask profile and did a source but still the java version shows 1.4

JAVA_HOME=/usr/local/jdk/jdk1.5.0_10/bin/java PATH has /usr/local/jdk/jdk1.5.0_10/bin

but i still see java -version even from the bin directory /usr/local/jdk/jdk1.5.0_10/bin as follows

java -version

java version "1.4.2" gcj (GCC) 3.4.6 20060404 (Red Hat 3.4.6-10.0.1) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

+4  A: 

but i still see java -version even from the bin directory /usr/local/jdk/jdk1.5.0_10/bin as follows

Magic: run ./java -version

Note the dot and slash - this tells to execute from current dir. Unlike DOS, on linux current dir is not in the executable search path by default

And yes, fix your $PATH

Yoni Roit
which java shows me #which java/usr/bin/java
$ ./java -versionjava version "1.5.0_06"Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
what needs to be fixed in $PATH? Shall I move the java path in the beginning of the path?
yep, move it to the beginning
Yoni Roit
+4  A: 

You need to use the alternatives system to update the symlinks to the correct version of Java - see http://kbase.redhat.com/faq/docs/DOC-5593.

Install with:

/usr/sbin/alternatives --install /usr/bin/java java /opt/jre1.6???/bin/java 2

Configure with:

/usr/sbin/alternatives --config java
Ninefingers
$ /usr/sbin/alternatives --display javajava - status is auto. link currently points to /usr/lib/jvm/jre-1.4.2-gcj/bin/java/usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1420 slave jre: /usr/lib/jvm/jre-1.4.2-gcj slave jre_exports: /usr/lib/jvm-exports/jre-1.4.2-gcj slave rmiregistry: /usr/lib/jvm/jre-1.4.2-gcj/bin/rmiregistryCurrent `best' version is /usr/lib/jvm/jre-1.4.2-gcj/bin/java.
this command is nto working /usr/sbin/alternatives --install /usr/bin/java java /opt/jre1.6???/bin/java 2
sorry, the ???? marks are for you to fill in based on your path to the version of the JRE you are installing - it might not even be in opt - on Fedora mine is located at /usr/java/jdk1.6.0_17/bin/java etc.
Ninefingers
+1  A: 

Try issuing the command "which java" to discover exactly what version of the java command is being executed. If you just appended the new path to the end of your PATH, then the shell will still use the old one because it'll find that one first.

TMN
+1  A: 

Generally each distro has their own mechanism for choosing the version of Java to use. Also this mechanism generally allows Java to be setup differently for each user.

Ubuntu - sudo update-alternatives --config java

Debian

Gentoo - Uses java-config

Fedora Core uses alternatives --config java

Steve g