Linux下安装 Java

2021-05-14 06:27

阅读:710

标签:i686   lda   arc   在线   doc   文件   root   color   roo   

一、在线下载 Java JDK 环境

(1)搜索 yum 库有什么 JDK 版本

[root@localhost ~]# yum search java | grep jdk
ldapjdk-javadoc.noarch : Javadoc for ldapjdk
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
.....
.....

 

(2)根据自己的需要选择下载库中对应版本的JDK

[root@localhost opt]# yum install java-1.8.0-openjdk

 

二、进入JDK目录中

[root@localhost jvm]# cd /usr/lib/jvm
[root@localhost jvm]# ls
java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
jre
jre-1.8.0
jre-1.8.0-openjdk
jre-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
jre-openjdk

 

三、设置Java的环境变量

[root@localhost jvm]# vim /etc/profile

在profile文件末尾追加上如下信息:

#Java environment
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

让配置文件生效

[root@localhost jvm]# source /etc/profile

 

四、查看Java环境是否设置成功

[root@localhost jvm]# java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

看到版本信息之后,我们知道Java环境已经配置好了呀 ~

 



Linux下安装 Java

标签:i686   lda   arc   在线   doc   文件   root   color   roo   

原文地址:https://www.cnblogs.com/xiaowei123/p/13125916.html

上一篇:defer in C++/Objc

下一篇:Spring框架


评论


亲,登录后才可以留言!