2

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.

2
  • Then you are not done. Always check "type java". Commented Feb 8, 2011 at 16:24
  • 2
    You might have installed more than one java version right now. Check out, where all the java versions are located by: whereis java Commented Feb 8, 2011 at 16:24

4 Answers 4

7

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.

Sign up to request clarification or add additional context in comments.

2 Comments

@Laki: How did you install 1.5? Doesn't sound like it was with yum
i installed weblogic server. it came with JDK 1.5
4

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

4 Comments

Is update-alternatives available on Redhat? I always thought it was a Debian tool and thus only available on Debian-based distributions.
@Joachim Sauer: Yes - it was created by them: alternatives is copyright 2002 Red Hat, Inc
oh, I see, it's a different piece of software with a similar name, then. Debian update-alternatives has Copyrights 1995, 200-2002 and 2009.
@Joachim Sauer: It's strange (and confusing) that they picked the same name! They even appear to work very much alike and share the same directory (/etc/alternatives) - perhaps some forking has occurred.
1

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

2 Comments

i already did that. problem is echo $PATH and echo $JAVA_HOME gives the 1.5 version but Java -version still gives 1.4
@Laki - that is not possible if $PATH and $JAVA_HOME are set correctly ... unless you've somehow got an alias or shell function with the name "java". Run "type java" and see what the command resolves to.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.