Install JDK1.7 in CentOS

Source: Internet
Author: User
1. source code package preparation: first download jdk and supervisor from the official website.

1. source code package preparation:

First, download jdk and supervisor from the official website.

 

2. decompress the source code package.

Create a java folder in the/usr/local directory on the terminal and run the following command:

sudo mkdir /usr/local/java

Copy the downloaded package to the java folder and run the following command:

Go to the directory where the jdk source code package is located

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

Go to the java directory and run the following command:

cd /usr/local/java

Decompress the package and run the following command:

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

Then you can delete the compressed package. command line:

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

 

3. set jdk environment variables

The global setting method is used to modify the etc/profile, which is an environment variable shared by all users.

sudo gedit /etc/profile

Open and 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

 

Remember, do not add spaces on both sides of the equal sign during the above process. otherwise, "invalid identifiers" will appear, because unnecessary spaces cannot be identified during source/etc/profile, it is understood as part of the path.

Then save

source /etc/profile

Make profile take effect

 

4. check whether the installation is successful.

On the terminal

java -version

Check whether the installation is successful

The result is as follows:

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.