Method 1: Install with the yum command
1. View current JDK version: Java–version, or: Rpm-qa | grep JDK
2. Remove the current jdk:yum-y remove java-1.6.0-openjdk
3. View the available JDK versions in the Yum repository: Yum search jdk
4. Install Java version 1.7:
Yum Install JAVA-1.7.0-OPENJDK
Yum Install Java-1.7.0-openjdk-devel
The default installation is in the/usr directory.
5. Do not configure the Java environment variables.
Method Two, install the package installation
1. Copy the installation package jdk-7u79-linux-x64.gz to the directory/usr/local/java
2. Unzip: TAR-ZXVF jdk-7u79-linux-x64.gz generate installation directory jdk1.7.0_79
3. Configure Environment variables
Modify the/etc/profile and add the following on the last side:
#set Java Environment
java_home=/usr/local/java/jdk1.7.0_79
Class_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Path= $JAVA _hoem/bin: $PATH
Export Java_home Class_path PATH
Tomcat's startup script automatically gets the value of java_home from the environment variable, so that Tomcat runs with the JDK specified by Java_home.
4. You can specify a JDK for Tomcat.
When multiple versions of the JDK are installed in the system, you can specify the JDK version for Tomcat.
Add the following line to the white space at the beginning of the catalina.sh file and the setclasspath.sh file:
Export java_home=/usr/loca/java/jdk1.7.0_79
Linux installation JDK and tomcat specified JDK version