The following operations are performed on the Aliyun server. The default yum source is Aliyun.If the default is not Aliyun or 163, it is recommended to modify it before yum operation. Modify yum source to Ali source
Check if installed
rpm -qa | grep java
rpm -qa | grep jdk
rpm -qa | grep gcj
No output means no installation
See if you want to retrieve a list containing Java 1.8
[root@Spider1 ~]# yum list java-1.8*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
java-1.8.0-openjdk.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-accessibility.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-accessibility-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-accessibility-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-demo.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-demo-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-demo-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-devel.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-devel-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-devel-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-headless.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-headless-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-javadoc-debug.noarch 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-javadoc-zip.noarch 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-javadoc-zip-debug.noarch 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-src.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-src.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-src-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-src-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
Install all files under Java 1.8
yum install java-1.8.0-openjdk* -y
Verification
This installation eliminates the need to configure environment variables
[root@Spider1 ~]# java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
[root@Spider1 ~]# jps
3721 Jps
[root@Spider1 ~]# javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
......slightly
You can find that commands such as jps, javac can execute without manually configuring environment variables.