I installed JDK 1.5 on RedHat 5 and set the paths 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:
Repeat for "javac" if you do Java development.
yumYou should use update-alternatives to set the preferred version of java. See this.
update-alternatives available on Redhat? I always thought it was a Debian tool and thus only available on Debian-based distributions.alternatives is copyright 2002 Red Hat, Incupdate-alternatives has Copyrights 1995, 200-2002 and 2009./etc/alternatives) - perhaps some forking has occurred.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.
whereis java