Yum mode
1. View each version in Yum
Yum-y List java*
2. Select a version to install (e.g. 1.7)
Yum-y Install java-1.7.0-openjdk*
3. You can view the version information after the installation is complete.
Java-version//If the version information is printed stating that the installation was successful, yum Setup automatically sets environment variables without manual setup
RPM mode
1, go to http://www.oracle.com/technetwork/java/javase/downloads/index.html Download the Java JDK rpm package, such as (JDK-7U79-LINUX-X64.RPM)
2, Rpm-ivh jdk-7u79-linux-x64.rpm
3. Setting Environment variables
Using the Vim/etc/profile configuration file, add the following Java environment configuration at the end of the file
Java_home=/usr/java/jdk1.7.0_79jre_home=/usr/java/jdk1.7.0_79/jreclass_path=.: $JAVA _home/lib/dt.jar: $JAVA _home /lib/tools.jar: $JRE _home/libpath= $PATH: $JAVA _home/bin: $JRE _home/binexport java_home jre_home class_path PATH
4, Source/etc/profile
Installing Java JDK on Linux