先删除centos自带的openjdk

查看当前系统的jdk

[parallels@10 program]$ rpm -qa | grep java

tzdata-java-2018e-3.el7.noarch

java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64

javapackages-tools-3.4.1-11.el7.noarch

java-1.7.0-openjdk-headless-1.7.0.191-2.6.15.4.el7_5.x86_64

java-1.8.0-openjdk-headless-1.8.0.181-3.b13.el7_5.x86_64

python-javapackages-3.4.1-11.el7.noarch

java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64

 

卸载删除

[parallels@10 program]$ sudo  rpm -e --nodeps java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64

[sudo] parallels 的密码:

[parallels@10 program]$ sudo rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.191-2.6.15.4.el7_5.x86_64

[parallels@10 program]$ sudo rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.181-3.b13.el7_5.x86_64

[parallels@10 program]$ sudo rpm -e --nodeps java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64

 

下载jdk,这里用下载java8为例

下载地址:

https://download.oracle.com/otn/java/jdk/8u261-b12/a4634525489241b9a9e1aa73d9e118e6/jdk-8u261-linux-x64.tar.gz

下载后在目录解压jdk版本

 tar -zxvf jdk-8u261-linux-x64.tar.gz 

修改配置文件

[parallels@10 jdk1.8.0_261]$ sudo vim /etc/profile

在文件末尾增加配置

#java environment

export JAVA_HOME=/home/parallels/program/jdk1.8.0_261

export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar

export PATH=$PATH:${JAVA_HOME}/bin

执行命令,让配置文件立即生效

[parallels@10 jdk1.8.0_261]$ sudo vim /etc/profile

查看java是否成功

[parallels@10 jdk1.8.0_261]$ java -version

java version "1.8.0_261"

Java(TM) SE Runtime Environment (build 1.8.0_261-b12)

Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

1 对 “centos安装jdk”的想法;

发表评论

电子邮件地址不会被公开。