安利:一文打尽 openjdk8 升级 11
Posted 闭关苦炼内功
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安利:一文打尽 openjdk8 升级 11相关的知识,希望对你有一定的参考价值。
由于某些原因,需要依赖openjdk11环境,所以就是这篇文章的来源
其实,现在大部分还都是使用jdk8
1、查看系统环境
[root@localhost ~]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (AltArch)
[root@localhost ~]#
2、查看已经配好的openjdk8环境
- 查看现有版本(之前已经配好)
[root@localhost ~]# java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
[root@localhost ~]#
- 查看环境变量 JAVA_HOME
[root@localhost ~]# echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-1.el7.aarch64/
[root@localhost ~]#
3、下面开始卸载原有openjdk
- 卸载openjdk8
[root@localhost jvm]# rpm -qa | grep java-1.8.0
java-1.8.0-openjdk-headless-1.8.0.262.b10-1.el7.aarch64
java-1.8.0-openjdk-1.8.0.262.b10-1.el7.aarch64
java-1.8.0-openjdk-devel-1.8.0.262.b10-1.el7.aarch64
[root@localhost jvm]#
[root@localhost jvm]# yum -y remove java-1.8.0-openjdk-headless
[root@localhost jvm]# rpm -qa | grep java-1.8.0
[root@localhost jvm]#
- 卸载openjdk7
[root@localhost jvm]# rpm -qa | grep java-1.7.0
java-1.7.0-openjdk-1.7.0.191-2.6.15.5.el7.aarch64
java-1.7.0-openjdk-headless-1.7.0.191-2.6.15.5.el7.aarch64
[root@localhost jvm]#
[root@localhost jvm]# yum -y remove java-1.7.0-openjdk
[root@localhost jvm]#
[root@localhost jvm]# yum -y remove java-1.7.0-openjdk-headless
[root@localhost jvm]#
[root@localhost jvm]# rpm -qa | grep java-1.7.0
[root@localhost jvm]#
4、安装openjdk11
- yum搜索openjdk11
[root@localhost jdk11]# yum search java-11-openjdk
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determining fastest mirrors
================================================================ N/S matched: java-11-openjdk ================================================================
java-11-openjdk.aarch64 : OpenJDK Runtime Environment 11
java-11-openjdk-demo.aarch64 : OpenJDK Demos 11
java-11-openjdk-devel.aarch64 : OpenJDK Development Environment 11
java-11-openjdk-headless.aarch64 : OpenJDK Headless Runtime Environment 11
java-11-openjdk-javadoc.aarch64 : OpenJDK 11 API documentation
java-11-openjdk-javadoc-zip.aarch64 : OpenJDK 11 API documentation compressed in a single archive
java-11-openjdk-jmods.aarch64 : JMods for OpenJDK 11
java-11-openjdk-src.aarch64 : OpenJDK Source Bundle 11
java-11-openjdk-static-libs.aarch64 : OpenJDK libraries for static linking 11
Name and summary matches only, use "search all" for everything.
[root@localhost jdk11]#
- yum安装openjdk11
[root@localhost ~]# yum -y install java-11-openjdk
Installed:
java-11-openjdk-devel.aarch64 1:11.0.8.10-1.el7
Complete!
[root@localhost ~]#
- 查看安装的openjdk11
[root@localhost jvm]# rpm -qa | grep java-11
java-11-openjdk-11.0.8.10-1.el7.aarch64
java-11-openjdk-devel-11.0.8.10-1.el7.aarch64
java-11-openjdk-headless-11.0.8.10-1.el7.aarch64
[root@localhost jvm]#
- 配置openjdk11环境变量
[root@localhost jvm]# vim /etc/profile
[root@localhost jvm]#
[root@localhost jvm]# source /etc/profile
[root@localhost jvm]#
[root@localhost jvm]# pwd
/usr/lib/jvm
[root@localhost jvm]#
[root@localhost jvm]# echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-11.0.8.10-1.el7.aarch64
[root@localhost jvm]#
[root@localhost jvm]# java -version
openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode, sharing)
[root@localhost jvm]#
贴出来环境变量关键部分
vim /etc/profile
#export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-1.el7.aarch64/
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.8.10-1.el7.aarch64/
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
打完收工!
各位小伙伴们,都看到最后了,点个赞支持一下再走呗!
以上是关于安利:一文打尽 openjdk8 升级 11的主要内容,如果未能解决你的问题,请参考以下文章