1

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!

GavinWoods
  • 813
  • 2
  • 14
  • 28
  • Voted to move this to [Superuser](http://superuser.com). In the meantime, take a look at the [`alternatives`](http://linux.about.com/library/cmd/blcmdl8_alternatives.htm) command. It should help you with this. – eldarerathis Oct 13 '10 at 21:09
  • @eldarerathis: RHEL -> serverfault. – Dummy00001 Oct 13 '10 at 22:27

1 Answers1

3

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
  • 26,542
  • 13
  • 70
  • 109
  • 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. – GavinWoods Oct 14 '10 at 18:51
  • You could just run 'source ~/.bash_profile' to reload .bash_profile, there is no need to restart. More info: http://stackoverflow.com/questions/4608187/how-to-reload-bash-profile-from-the-command-line – Deepak Joy Cheenath Nov 15 '12 at 12:14