1. installation Package Preparation:
First download the jdk,http://www.oracle.com/technetwork/java/javase/downloads/website jdk7-downloads-1880260.html, I download jdk-7u45-linux-x64.tar.gz, download to home directory
2. Unzip the source package
Create a new Java folder from the terminal in the/usr/local directory, command line:
sudo mkdir/usr/local/java
Then copy the download to the archive into the Java folder, the command line:
Enter the directory where the JDK source package resides
CP Jdk-7u45-linux-x64.tar.gz/usr/local/java
Then go to the Java directory, command line:
Cd/usr/local/java
Unzip the Tarball, command line:
sudo tar xvf jdk-7u45-linux-x64.tar.gz
You can then delete the compressed package, command line:
sudo rm jdk-7u45-linux-x64.tar.gz
3. Setting the JDK environment variable
The global setting method here is to modify Etc/profile, which is a common environment variable for all users.
sudo gedit/etc/profile
After opening, add at the end
Export Java_home=/usr/local/java/jdk1.7.0_45export Jre_home=/usr/local/java/jdk1.7.0_45/jreexport CLASSPATH=.:$ Java_home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib: $CLASSPATHexport path= $JAVA _home/bin: $PATH
Keep in mind that during the add-on process, do not add a space on either side of the equal sign, or "not a valid identifier", because the Source/etc/profile does not recognize the extra space and is understood to be part of the path.
and then save
Source/etc/profile
Make profile effective
4, check whether the installation is successful
In the terminal
Java-version
See if the installation is successful
Success shows the following
Java Version "1.7.0_45"
Java (TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot (TM) 64-bit Server VM (build 24.45-b08, Mixed mode)
Installing JDK1.7 under CentOS