views:

38

answers:

1

Hello,

I am having a problem in Red Hat Enterprise Linux, I'm a newb to Linux so this is probably something very simple. I installed a new 64-bit JDK (1.6.0_18) on RHEL 5 (64-bit), and now i need to set the path so that linux will go for the 1.6.0_18 instead of the old JRE 1.4.2. But everytime i set the path variable, its like the changes are immediately undone.

Here are the steps I took:

  1. Log in as root
  2. Open Terminal, run the command: "export PATH=$PATH:/usr/java/jdk1.6.0_18/bin"
  3. Run "echo $PATH", the new path returns
  4. Run "java -version", the old jre shows up.
  5. Start up a new terminal, run "echo $PATH", the new path i added no longer shows up.

Thanks in advance!

+1  A: 

While I also think you should ask this in superuser or serverfault..

Try

export PATH=/usr/java/jdk1.6.0_18/bin:$PATH

instead, and while you are at it, this will ensure other scripts etc. would work

export JAVA_HOME=/usr/java/jdk1.6.0_18
export JAVA=/usr/java/jdk1.6.0_18/bin/java

If you want to persist these changes, try putting the above lines in .bash_profile or something.

The reason the above works and yours doesn't, is that the system searches from what's left in the PATH first. So if there are 2 java the system could use in the PATH, it will use the first one found.

Enno Shioji
Thank you for your help! I had to edit the .bash_profile configuration file, then reboot in order for the changes to take effect. After that everything was great! Btw: Ty for the suggestion to post to superuser or serverfault in the future. I've gotten used to posting my programming questions on here, forgot about those other sites.
Gavin