阿里云centos7服务器卸载openJDK并安装jdk

1.查看已经安装的jdk
rpm -qa|grep jdk
显示结果如下
java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64
java-1.8.0-openjdk-headless-1.8.0.161-0.b14.el7_4.x86_64
copy-jdk-configs-2.2-5.el7_4.noarch
 
2.用yum卸载openJDK
yum -y remove java-1.8.0-openjdk-headless-1.8.0.161-0.b17.el7.x86_64
3.查看java版本是否已经卸载
java -version
-bash: java: 未找到命令
 
4.使用wget下载压缩包
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"
5.进入/usr/local创建java目录
cd /usr/local
mkdir java
cd ~
 
6.解压到/usr/local/java
tar -zxvf jdk-8u141-linux-x64.tar.gz -C /usr/local/java/
 
7.安装完毕之后在/etc/profile文件末尾添加
vim /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_141
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
8.使/etc/profile生效
source /etc/profile
 
9.再次查看java是否安装成功
java -version 

显示结果如下

java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)

10.创建软连接

cd /usr/bin
ln -s -f /usr/local/java/jdk1.8.0_141/bin/java


 

 

你可能感兴趣的:(centos7最厉害的服务器)