我创建了一个文件/etc/profile.d/java.sh,其中包括(其中包括)以下代码行:export JAVA_HOME = /usr/java / jdk1.6.0_30.但是,当我通过SSH登录或重新启动linux Centos 6.2服务器时,总是看到:
[root@host3 /etc/profile.d]# echo $JAVA_HOME
/usr/local/jdk
这是一个新的安装和服务器,因此没有太多其他工作.似乎java.sh文件在重新引导或SSH登录后正在执行,但是,JAVA_HOME的值已被/usr/local/jdk的缺省值覆盖. /usr/local下甚至没有目录jdk.
任何想法如何纠正这一点?需要为所有用户设置JAVA_HOME的值(在java.sh中完成).
更新1:
我检查了/ etc / profile文件,并搜索了文本jdk和JAVA,均未找到.我还检查了/root/.bash_profile,它显示如下:
# .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
另外,如果我获取java.sh的源代码,则一切设置正确.但是,如果我重新启动服务器,JAVA_HOME将返回到/usr/local/jdk.
解决方法:
检查主目录中的/ etc / profile文件或.bash_profile / .profile.
标签:linux,java
来源: https://codeday.me/bug/20191101/1985788.html