拿什么来拯救自己 2020-06-14
一、在线下载 Java JDK 环境
(1)搜索 yum 库有什么 JDK 版本
[ ~]# 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
[ opt]# yum install java-1.8.0-openjdk
二、进入JDK目录中
[ jvm]# cd /usr/lib/jvm [ 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的环境变量
[ 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
让配置文件生效
[ jvm]# source /etc/profile
四、查看Java环境是否设置成功
[ 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环境已经配置好了呀 ~