RHEL 5 - Path Environment Variable Changes Don't Take Effect
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:
- Log in as root
- Open Terminal, run the command: "export PATH=$PATH:/usr/java/jdk1.6.0_18/bin"
- Run "echo $PATH", the new path returns
- Run "java -version", the old jre shows up.
- Start up a new terminal, run "echo $PATH", the new path i added no longer shows up.
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.
精彩评论