Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

incorrect java version in linux

Tags:

java

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.

like image 723
Laki Avatar asked Mar 21 '26 05:03

Laki


1 Answers

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.

like image 87
OMG Ponies Avatar answered Mar 22 '26 19:03

OMG Ponies