java version still showing as 1.4 linux
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 direct开发者_如何学Pythonory /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.
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
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
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
Oh, yes.
sudo update-alternatives --config java
Displays:
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk/jre/bin/java 1051 manual mode
Then you can choose your version. In my case, Java-7 (option 2)
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.
精彩评论