centos 8.3安装 OPENJDK

centos 8.3安装 OPENJDK

查找可安装的OPENJDK

[root@xamppr10 ~]# yum search java | grep -i --color openjdk

centos 8.3安装 OPENJDK
命令执行显示如下

[root@xamppr10 opt]# yum search java | grep -i --color openjdk
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-headless.x86_64 : The OpenJDK runtime environment without
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment 8
java-1.8.0-openjdk.x86_64 : OpenJDK 8 Runtime Environment
java-1.8.0-openjdk-accessibility.i686 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.8.0-openjdk-demo.i686 : OpenJDK Demos 8
java-1.8.0-openjdk-demo.x86_64 : OpenJDK 8 Demos
java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment 8
java-1.8.0-openjdk-devel.x86_64 : OpenJDK 8 Development Environment
java-1.8.0-openjdk-headless.i686 : OpenJDK Headless Runtime Environment 8
java-1.8.0-openjdk-headless.x86_64 : OpenJDK 8 Headless Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK 8 API documentation compressed
java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle 8
java-1.8.0-openjdk-src.x86_64 : OpenJDK 8 Source Bundle
java-11-openjdk.i686 : OpenJDK Runtime Environment 11
java-11-openjdk.x86_64 : OpenJDK 11 Runtime Environment
java-11-openjdk-demo.i686 : OpenJDK Demos 11
java-11-openjdk-demo.x86_64 : OpenJDK 11 Demos
java-11-openjdk-devel.i686 : OpenJDK Development Environment 11
java-11-openjdk-devel.x86_64 : OpenJDK 11 Development Environment
java-11-openjdk-headless.i686 : OpenJDK Headless Runtime Environment 11
java-11-openjdk-headless.x86_64 : OpenJDK 11 Headless Runtime Environment
java-11-openjdk-javadoc.i686 : OpenJDK 11 API documentation
java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentation
java-11-openjdk-javadoc-zip.i686 : OpenJDK 11 API documentation compressed in a
java-11-openjdk-javadoc-zip.x86_64 : OpenJDK 11 API documentation compressed in
java-11-openjdk-jmods.i686 : JMods for OpenJDK 11
java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11
java-11-openjdk-src.i686 : OpenJDK Source Bundle 11
java-11-openjdk-src.x86_64 : OpenJDK 11 Source Bundle
java-11-openjdk-static-libs.i686 : OpenJDK libraries for static linking 11
java-11-openjdk-static-libs.x86_64 : OpenJDK 11 libraries for static linking

安装自己想要安装的版本

我这里选择安装java-11-openjdk.x86_64
[root@xamppr10 ~]# yum install java-11-openjdk.x86_64 -y

centos 8.3安装 OPENJDK
命令执行显示忽略

查看安装openjdk版本

[root@xamppr10 ~]# java -version
命令执行显示如下
centos 8.3安装 OPENJDK

设置环境变量

查找安装java的目录

[root@xamppr10 ~]# which java
命令执行显示如下
centos 8.3安装 OPENJDK
-l:详细信息; -r:递归子文件夹
[root@xamppr10 ~]# ls -lr /usr/bin/java
命令执行显示如下
centos 8.3安装 OPENJDK
执行如下命令查看java安装路径
[root@xamppr10 ~]# ls -lr /etc/alternatives/java
centos 8.3安装 OPENJDK
java的安装路径为:
/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64/bin/java

编辑profile文件配置java环境变量

[root@xamppr10 ~]# vim /etc/profile
按键盘上的i键,进行编辑
添加如下信息:

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

centos 8.3安装 OPENJDK
按键盘上的Esc键,输入:wq

配置文件生效

[root@xamppr10 ~]# source /etc/profile

查看是否配置成功

[root@xamppr10 ~]# echo $PATH
/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64/bin:/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@xamppr10 ~]# echo $CLASSPATH
/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64/lib:/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64/jre/lib:

centos 8.3安装 OPENJDK

上一篇:使用Flask设计带认证token的RESTful API接口


下一篇:部署keepalive+lvs