linux重启后JDk环境变量配置失效

sudo su
mkdir -p /usr/lib/jvm
chmod -R 777 /usr/lib/jvm
mv /tmp/jdk-8u121-linux-x64.tar.gz /usr/lib/jvm/
tar -zxvf /usr/lib/jvm/jdk-8u121-linux-x64.tar.gz -C /usr/lib/jvm
vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_121  
export JRE_HOME=${JAVA_HOME}/jre  
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
export  PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile

如果电脑重启失效

将JDK的bin路径和jre的bin路径手动追加到/etc/bashrc

 export PATH=(原有环境变量....其后追加,注意冒号分隔哦) :/usr/jdk/bin:/usr/jdk/jre/bin 
vi /etc/bashrc
JAVA_HOME=/usr/lib/jvm/jdk1.8.0_121
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin
source /etc/bashrc

你可能感兴趣的:(java,基础)