开发者

RHEL 5 - Path Environment Variable Changes Don't Take Effect

开发者 https://www.devze.com 2023-01-20 08:24 出处:网络
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

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.
开发者_Go百科

Thanks in advance!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消