Laki
Laki

Reputation: 21

incorrect java version in linux

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.

Upvotes: 2

Views: 8679

Answers (4)

Laki
Laki

Reputation: 1

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.

Upvotes: 0

Stephen C
Stephen C

Reputation: 718678

After editing .bash_profile you either need to source it (using the "." builtin) or logout and login again. (Apologies if know this ... )

Upvotes: 1

OMG Ponies
OMG Ponies

Reputation: 332491

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.

Upvotes: 6

trojanfoe
trojanfoe

Reputation: 122381

You should use update-alternatives to set the preferred version of java. See this.

Upvotes: 4

Related Questions