Install JDK1.7 under CentOS

1. Source package preparation:

First go to the official website to download jdk , http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html , I download jdk-7u10-linux-x64.tar.gz , download to the main directory

 

2. Unzip the source package

Create a new java folder in the /usr/local directory through the terminal , command line:

sudo mkdir /usr/local/java

Then copy the downloaded compressed package to the java folder, command line:

Enter the directory where the jdk source package is located

cp jdk-7u10-linux-x64.tar.gz /usr/local/java

Then enter the java directory, the command line:

cd /usr/local/java

Unzip the compressed package, command line:

sudo tar xvf jdk-7u10-linux-x64.tar.gz

Then you can delete the compressed package, the command line:

sudo rm jdk-7u10-linux-x64.tar.gz

 

3. Set the jdk environment variable

The global setting method is used here, which is to modify etc/profile , which is a common environment variable for all users

vi /etc/profile

add at the end after opening

export JAVA_HOME=/usr/local/java/jdk1.7.0_10

export JRE_HOME=/usr/local/java/jdk1.7.0_10/jre

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH

export PATH=$JAVA_HOME/bin: $PATH

  Press esc to quit editing then type : wq or ctrl+x to save and close the file   

 

4. Check whether the installation is successful

in the terminal

java -version

Check if the installation is successful

If successful, it will display as follows

java -version
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326686931&siteId=291194637