centos7安装JDK步骤

centos hykeda 454℃ 0评论

卸载旧版本的JDK:
 
1. 确定JDK的版本:
rpm -qa | grep jdk

2.卸载JDK
yum -y remove jdk1.8-1.8.0_161-fcs.x86_64
卸载用rpm安装的jdk
rpm -e –nodeps jdk1.8-1.8.0_161-fcs

下载 最新的JDK包,并重命名为jdk-8u161-linux-x64.rpm
wget -O jdk-8u161-linux-x64.rpm http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm?AuthParam=1518156231_aa2553da1635a779786c3a861b3a4589

安装JDK
rpm -ivh jdk-8u161-linux-x64.rpm

配置环境变量
输入命令:vi /etc/profile
在/etc/profile文件中加入: 

export JAVA_HOME=/usr/java/jdk1.8-1.8.0_161-fcs 
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib 
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin

按esc,:wq保存退出
source /etc/profile 生效配置

java -version 查看是否安装成功
java version “1.8.0_161”
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

转载请注明:雕木乱 » centos7安装JDK步骤

喜欢 (0)

您必须 登录 才能发表评论!