1、vi /etc/profile
#set java environment
JAVA_HOME=/service/jdk
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
立即生效:
source /etc/profile
2、vi /etc/bashrc
#set java environment
JAVA_HOME=/service/jdk
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
立即生效:
source /etc/bashrc
3、配置被覆盖或未生效,请参考linux配置文件加载顺序
https://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_010.html
https://blog.csdn.net/bjnihao/article/details/51775854