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
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
Userpm
Command 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.