java centos7配置查看jdk环境变量
[root@bogon java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64]# which java
/usr/bin/java
[root@bogon java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64]# ls -lrt /usr/bin/java
lrwxrwxrwx. 1 root root 22 4月 30 01:07 /usr/bin/java -> /etc/alternatives/java
[root@bogon java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64]# ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 73 4月 30 01:07 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java
[root@bogon java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64]#
至此断定jdk安装路径为:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
vi /etc/profile
在最后面加上:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64 export JRE_HOME=$JAVA_HOME/jre export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
保存退出
source /etc/profile
验证:
echo $JAVA_HOME
[root@bogon java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64]# echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64