Install JDK online for CentOS and jdk online for centos
1. Install jdk online using the yum command
1. view the jdk version currently supported on the cloud
[root@localhost ~]# yum search java|grep jdkldapjdk-javadoc.noarch : Javadoc for ldapjdkjava-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environmentjava-1.6.0-openjdk-demo.x86_64 : OpenJDK Demosjava-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environmentjava-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentationjava-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundlejava-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environmentjava-1.7.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connectorjava-1.7.0-openjdk-demo.x86_64 : OpenJDK Demosjava-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environmentjava-1.7.0-openjdk-headless.x86_64 : The OpenJDK runtime environment withoutjava-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentationjava-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundlejava-1.8.0-openjdk.i686 : OpenJDK Runtime Environmentjava-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environmentjava-1.8.0-openjdk-accessibility.i686 : OpenJDK accessibility connectorjava-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connectorjava-1.8.0-openjdk-accessibility-debug.i686 : OpenJDK accessibility connectorjava-1.8.0-openjdk-accessibility-debug.x86_64 : OpenJDK accessibility connectorjava-1.8.0-openjdk-debug.i686 : OpenJDK Runtime Environment with full debug onjava-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment with full debug onjava-1.8.0-openjdk-demo.i686 : OpenJDK Demosjava-1.8.0-openjdk-demo.x86_64 : OpenJDK Demosjava-1.8.0-openjdk-demo-debug.i686 : OpenJDK Demos with full debug onjava-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos with full debug onjava-1.8.0-openjdk-devel.i686 : OpenJDK Development Environmentjava-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environmentjava-1.8.0-openjdk-devel-debug.i686 : OpenJDK Development Environment with fulljava-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment withjava-1.8.0-openjdk-headless.i686 : OpenJDK Runtime Environmentjava-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environmentjava-1.8.0-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with fulljava-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with fulljava-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentationjava-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK API Documentation for packagesjava-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK API Documentation compressed injava-1.8.0-openjdk-javadoc-zip-debug.noarch : OpenJDK API Documentationjava-1.8.0-openjdk-src.i686 : OpenJDK Source Bundlejava-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundlejava-1.8.0-openjdk-src-debug.i686 : OpenJDK Source Bundle for packages withjava-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle for packages withldapjdk.noarch : The Mozilla LDAP Java SDK
2. Select a version and install it. (The jdk dependency is automatically installed by running the following command)
[Root @ localhost ~] # Yum install-y java-1.8.0-openjdk loaded plug-in: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: FIG * updates: mirrors.aliyun.com is working on dependencies --> checking transactions --> the package java-1.8.0-openjdk.x86_64.1.1.8.0.151-5.b12.el7_4 will be installed --> processing dependency java-1.8.0-openjdk-headless (x86-64) =. 8.0.151-5. b12.el7 _ 4, which is required by the Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> is processing dependency xorg-x11-fonts-Type1, which is required by the Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> is processing dependency libpng15.so. 15 (PNG15_0) (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> is processing dependency libjvm. so (SUNWprivate_1.1) (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependencies libjpeg. so.62 (lib1__6.2) (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependencies libjli. so (SUNWprivate_1.1) (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependencies libjava. so (SUNWprivate_1.1) (64bit), which is required by the Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> is processing the dependency fontconfig (x86-64), which is the Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 needs --> processing dependency libpng15.so. 15 () (64bit), which is required by the Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependency libjvm. so () (64bit), which is required by the Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependencies libjpeg. so.62 () (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependency libjli. so () (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> is processing dependency libjava. so () (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> is processing dependency libgif. so.4 () (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependency libawt. so () (64bit), which is required by the Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependencies libXtst. so.6 () (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependency libXrender. so.1 () (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependency libXi. so.6 () (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependency libXext. so.6 () (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependencies libXcomposite. so.1 () (64bit), which is required by Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64 --> processing dependencies libX11.so. 6 () (64bit), it is required by the Software Package 1: java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64
......
3. Check whether the installation is successful.
[root@localhost ~]# java -versionopenjdk version "1.8.0_151"OpenJDK Runtime Environment (build 1.8.0_151-b12)OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
4. Search for the java file and find the default jdk installation directory.
[root@localhost ~]# find / -name 'java'/etc/pki/ca-trust/extracted/java/etc/pki/java/etc/java/etc/alternatives/java/var/lib/alternatives/java/usr/bin/java/usr/lib/java/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64/jre/bin/java/usr/share/java
Tip: Install jdk online using the yum command, which is simple and convenient. You can use java services without configuring environment variables.