# yum -y list 搜索演示 $ yum -y list java Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * updates: mirrors.aliyun.com Available Packages java-1.6.0-openjdk.x86_64 1:1.6.0.41-1.13.13.1.el7 ... java-1.8.0-openjdk-headless.x86_64 l:1.8.0.212.b04-0.el7_6 java-1.8.0-openjdk.x86_64 1:1.8.0.212.b04-0.el7_6 # yum search jdk 搜索演示 $ yum search jdk ====================================== N/S matched: jdk ====================================== copy-jdk-configs.noarch : JDKs configuration files copier java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment 8 ... java-11-openjdk-debug.x86_64 : OpenJDK Runtime Environment 11 with full debug on
$ yum install java-1.8.0-openjdk.x86_64 Installed: java-1.8.0-openjdk.x86_64 1:1.8.0.292.b10-1.el7_9 Dependency Installed: atk.x86_64 0:2.28.1-2.el7 copy-jdk-configs.noarch 0:3.3-10.el7_5 giflib.x86_64 0:4.1.6-9.el7 gtk-update-icon-cache.x86_64 0:3.22.30-6.el7... xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 Dependency Updated: chkconfig.x86_64 0:1.7.6-1.el7 Complete!
$ ls -l /usr/lib/jvm total 0 drwxr-xr-x 3 root root 16 Aug 3 22:53 java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64 lrwxrwxrwx 1 root root 21 Aug 3 22:53 jre -> /etc/alternatives/jre lrwxrwxrwx 1 root root 27 Aug 3 22:53 jre-1.8.0 -> /etc/alternatives/jre_1.8.0 lrwxrwxrwx 1 root root 35 Aug 3 22:53 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk lrwxrwxrwx 1 root root 51 Aug 3 22:53 jre-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64 -> java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64/jre lrwxrwxrwx 1 root root 29 Aug 3 22:53 jre-openjdk -> /etc/alternatives/jre_openjdk
#set java environment JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64 PATH=$PATH:$JAVA_HOME/bin CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME CLASSPATH PATH
$ java -version openjdk version "1.8.0_292" OpenJDK Runtime Environment (build 1.8.0_292-b10) OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
cd /etc/yum.repos.d/ mv CentOS-Base.repo CentOS-Base.repo_bak
# 阿里云yum源: wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum clean all yum makecache
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70003733/viewspace-2885181/ ,如需转载,请注明出处,否则将追究法律责任。