安装JDK
2019-08-05 本文已影响0人
yuhan_sining
1、检查是否安装了JDK: rpm -qa | grep jdk
2、如果已经安装了JDK,则卸载: yum -y remove [查询出来的包名]
yum -y remove java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64
yum -y remove java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
yum -y remove java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
yum -y remove copy-jdk-configs-1.2-1.el7.noarch
yum -y remove java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
**3、安装下载下来的JDK RPM包: **
rpm -ivh /home/workspace/zipped/jdk-8u172-linux-x64.rpm
4、设置JDK环境变量
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_172-amd64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile #环境变量生效