Install the java environment in CentOS

Source: Internet
Author: User

Install the java environment in CentOS
Preparation

In general, we need to uninstall the OPENJDK that comes with linux, and then install the sun jdk.

First, uninstall the built-in java

Check whether the JDK that comes with Linux is installed.
Run the following command to view the installed Java version.

java -version   

Run the following command to view the JDK information.

rpm -qa|grep java   

As shown in.

Uninstall installed JAVA, as shown in.

The uninstall is completed, as shown in.

Detach another one, as shown in.

The uninstall is completed, as shown in.

Step 2: Install SUN's JDK.

Official Website: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Create a java directory under/usr to install the java program in this directory. Enter the following command:

mkdir /usr/java 

Copy the downloaded installation file to the share folder of the original system and run the following command to view the file:

cd /mnt/share  ls -a  

Copy the file to the/usr/java directory and enter the following command:

cp *.gz /usr/java  

Run the following command to view the/usr/java directory:

cd /usr/java  ls -a  

Decompress the file and enter the following command: Linux code

tar -xzvf jdk-7u13-linux-x64.gz  

After decompression, a new directory jdk1.7.0 _ 13 will be generated under the/usr/java Directory, which stores the decompressed files. For later setup convenience, we changed the directory jdk1.7.0 _ 13 to jdk. Enter the following command:

mv jdk1.7.0_13 jdk  

Alternatively, if the downloaded file is in rpm format, replace the tar command with the following command to install it. The other steps remain unchanged.

rpm -ivh jdk-7u13-linux-x64.rpm 

Finally, set the environment variables. Enter the following command to enter the configuration file, or open the configuration file in other ways.

vi /etc/profile  

Go to the configuration file, as shown in. Delete the following 1st rows, and change the configuration information of the following 2-4 rows.

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROLexport JAVA_HOME=/usr/local/jdk1.7.0_79export PATH=$JAVA_HOME/bin:$PATHexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Make environment variables take effect. Execute the configuration file to make it take effect immediately. Enter the following command:

source /etc/profile  

Run the following command to verify whether the installation is successful:

Java -version  

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.