The default value for Java – JAVA_HOME seems to override :/etc/profile. The value of the d/java.sh setting
I created a file /etc/profile.d
/java .sh that includes (among other things) lines of code: export JAVA_HOME=/usr/java/jdk1 .6.0_30.
However, when I log in via SSH or restart the linux Centos 6.2 server, I always see:
[root@host3 /etc/profile.d]# echo $JAVA_HOME
/usr/local/jdk
It’s a new installation and server, so not much else has been done. It seems that the java.sh file is executing on reboot or SSH login, however, the value of JAVA_HOME is somehow overridden by the default value of /usr/local/jdk
. There is not even a directory jdk
under /usr/local
.
Any idea how to correct this? You need to set the value of JAVA_HOME for all users, as you did in java.sh.
Update 1:
I CHECKED THE /ETC/PROFILE FILE AND SEARCHED FOR THE TEXT JDK
AS WELL AS JAVA
, BUT FOUND NEITHER. I also checked /root/.bash_profile and it shows up as follows:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
Also, if I use java.sh, everything is set up correctly. But if I restart the server, JAVA_HOME goes back to /usr/local/jdk
.
Solution
Check the /etc/profile file or .bash_profile/.profile in your home directory.