Install and configure the java environment in CentOS

Source: Internet
Author: User
Get and download: Baidu jdk, go to the java official website, and download the corresponding version. In centos, select the rpm format of the linux installer. So we get the download URL, such as my: http://download.oracle.com/otn-pub/java/jdk/8u40-b26/jdk-8u40-linux-x64.rpm? Auth acquisition and download:

Baidu jdk: go to the java official website and download the corresponding version. In centos, select the rpm format of the linux installer.
 
In this way, we get the download URL, such as my:

Http://download.oracle.com/otn-pub/java/jdk/8u40-b26/jdk-8u40-linux-x64.rpm? AuthParam = 1426666028_afdc48de3eb5d4911ec5bd5274758138

Enter the following command in the centos command line to download it:

# wget http://download.oracle.com/otn-pub/java/jdk/8u40-b26/jdk-8u40-linux-x64.rpm?AuthParam=1426666028_afdc48de3eb5d4911ec5bd5274758138
  • 1

After the download is complete, we rename the file (mv command) for easy operation and good looks:

# mv jdk-8u40-linux-x64.rpm?AuthParam=1426666028_afdc48de3eb5d4911ec5bd5274758138 jdk-8u40-linux-x64.rpm
  •  
Install

UserpmCommand to install:

# rpm -ivh jdk-8u40-linux-x64.rpm

Parameter-ivh: The installation progress is displayed.-install-verbose-hash

JDK is installed in/usr/java by default.

# pwd/usr/java# lsdefault  jdk1.8.0_40  latest
Check whether the installation is successful:
# java -versionjava version "1.8.0_40"Java(TM) SE Runtime Environment (build 1.8.0_40-b26)Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

If the java version is available, the installation is successful.

Set the java system environment
# vi /etc/profile

Add the following content at the end of the profile file:

# Set java environmentJAVA_HOME =/usr/java/defaultJRE_HOME =/usr/java/default/jrePATH = $ PATH: $ JAVA_HOME/bin: $ JRE_HOME/binCLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar: $ JAVA_HOME/libexport JAVA_HOME JRE_HOME path classpath execute the source command to make it take effect:
# source profile

Check whether it takes effect:

# echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/java/default/bin:/usr/java/default/jre/bin:/root/bin

If the system PATH contains java or other words, it indicates that it takes effect.

Since then, the java environment has been installed in centos.

Related Article

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.