I installed JDK 1.5 on RedHat 5 and set the p开发者_如何学运维aths for JAVA_HOME and PATH in bash_profile. But java -version still shows 1.4
Appreciate if anyone have a solution to fix this issue.
The JREs can be managed using the /usr/sbin/alternatives function:
alternatives --config java
...will produce a list similar to:
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
*+ 2 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
Enter to keep the current selection[+], or type selection number:
- Follow the instructions to select a different JRE default by entering its Selection number, or press the "Enter" key to exit the prompt.
- The "+", found to the left of the Selection number, indicates which JRE is currently selected.
Repeat for "javac" if you do Java development.
You should use update-alternatives
to set the preferred version of java. See this.
After editing .bash_profile
you either need to source it (using the "." builtin) or logout and login again. (Apologies if know this ... )
Got this resolved.
which java /usr/bin/java
ls -la /usr/bin/java lrwxrwxrwx 1 root root 22 Jan 6 00:24 /usr/bin/java -> /etc/alternatives/java
ls -la /etc/alternatives/java /etc/alternatives/java -> /appl01/bea/jdk150_22/jre/bin/java
This is was linked to jre 1.4. Modified to point to jre 1.5 and it worked.
精彩评论