jdk7 download address http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Step 1: Check the permissions of the current user to rpm
[root@localhost software]# ls -l jdk-7u79-linux-x64.rpm
-rw-r--r--. 1 root root 138082565 Jul 23 00:29 jdk -7u79-linux-x64.rpm
Step 2: Add execute permission
[root@localhost software]# chmod 755 jdk-7u79-linux-x64.rpm
[root@localhost software]# ls -l jdk-7u79-linux-x64 .rpm
-rwxr-xr-x. 1 root root 138082565 Jul 23 00:29 jdk-7u79-linux-x64.rpm
Step 3: Use the rpm command to install
[root@localhost software]# rpm -ivh jdk-7u79- linux-x64.rpm
Preparing... ################################# [100%]
Updating / installing. ..
1:jdk-2000:1.7.0_79-fcs ################################# [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
Step 4: java -version to see if it is successful
[root@localhost software]# java -version
java version "1.7.0_79 "
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
Step 5: View the java installation location
[root@localhost jdk1.7.0 _79]# find / -name java
find: ?.run/user/1000/gvfs?. Permission denied
/etc/pki/ca-trust/extracted/java
/etc/pki/java
/usr/bin/java
/usr/ java
/usr/java/jdk1.7.0_79/bin/java
/usr/java/jdk1.7.0_79/jre/bin/java
Step 6: Write a Hello for testing
[root@localhost jdk1.7.0_79]# ls
[root@localhost jdk1.7.0_79]# vi Hello.java
public class Hello{
public static void main(String[] args ){
System.out.println("test");
}
}
[root@localhost jdk1.7.0_79]# vi Hello.java
public class Hello{
public static void main(String[] args ){
System.out.println("test");
}
}
[root@localhost jdk1.7.0_79]# javac Hello.java
[root@localhost jdk1.7.0_79]# java Hello
test
Notice:
The above installation does not modify the ect/profile file, and it can be executed by adding environment variables, but it is recommended to set environment variables for subsequent software installations such as tomcat
Modify the /etc/profile file and add the following information at the end:
JAVA_HOME=/usr/java/jdk1.7.0_79
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/ lib/tools.jar
export JAVA_HOME PATH CLASSPATH
save and launch
source /etc/profile
Client company configuration
export JAVA_HOME=/usr/java/jdk1.7.0_15
export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$PATH:$JAVA_HOME/bin
export JRE_HOME=$JAVA_HOME/jre