1, download JDK (Linux version)
Official website Download: http://www.oracle.com/technetwork/java/javase/downloads/index.html
2, create Java directory (can be ignored)
mkdir /usr/local/java
3, unzip the JDKif the download is *.tar.gz (*.tar.gz is the JDK file name)
tar -zxvf *. tar. gz
if the download is *.rpm (*.rpm is the JDK file name)
Rpm2cpio *.rpm | Cpio-div
4. Unpack the jar package (jdk1.7.0_79 is the JDK directory)in the jdk1.7.0_79/lib/directory and the jdk1.7.0_79/jre/lib/directory, there are tools.pack and rt.pack files that need to be decompressed to Tools.jar and Rt.jar (requires root user action)1, switch root user (need to enter a password, if not previously used root account, you need to set the password, set the password method to search by themselves)
su root
2, Unzip (enter the Jdk1.7.0_79/jre/bin directory, enter the following command)
unpack200. /lib/rt.pack. /lib/rt.jarunpack200. /.. /lib/tools.pack. /.. /lib/tools.jar
5, explain the pressure of the JDK copied to the 2nd step in the new directory (jdk1.7.0_79 is the JDK directory)
CP -R JDK1. 7. 0_79/usr/local/java/
The PS:JDK directory is not the directory that is extracted directly, but the directory in the Usr/java of the extracted directory.
6, adding environment variables1. Open profile file
sudo gedit/etc/profile
2, add the following at the bottom
1 java_home=/usr/local/java/jdk1. 7 . 0_79 2 path= $JAVA _home/bin: $JAVA _home/jre/Bin: $PATH3 classpath=.: $JAVA _home/lib: $JAVA _home /jre/Lib4export java_home5exportPATH6 Export CLASSPATH
3, the variable takes effect, after saving and exiting the profile file, enter
Source/etc/profile
7. Detection (Enter the following command)
Java-version
Print out JDK version information, install correctly
Linux JDK Installation