CentOS7配置JAVA环境变量
1、移除CentOS7自带的openjdk
CentOS7操作系统自带了jdk,可通过以下命令查看 ``` rpm -qa | grep java ``` ![](https://images2018.cnblogs.com/blog/1373276/201808/1373276-20180814143410707-1216522338.png)移除自带的jdk
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.51-2.4.5.5.el7.x86_64
2、安装自带的jdk
CentOS7自带了sz和rz命令,可通过rz命令打开文件选择对话框,可将主机的文件传输至虚拟机 ![](https://images2018.cnblogs.com/blog/1373276/201808/1373276-20180814145150235-206237963.png)解压jdk1.8
tar -zxvf tar -zxvf jdk-8u171-linux-x64.tar.gz
配置环境变量,编辑/etc/profile文件
vim /etc/profile
添加下面两行配置
export JAVA_HOME=/usr/software/jdk1.8.0_171
export PATH=$PATH:$JAVA_HOME/bin
保存,退出,让profile文件生效
source /etc/profile
3、查看已安装的jdk
java
javac
java -version