Copyright statement: This article is the original article of the blogger, please indicate the source for reprinting. https://blog.csdn.net/gongxifacai_believe/article/details/53082077
Operating system version: CentOS Linux release 7.2.1511 (Core)
JDK version: jdk-8u111-nb-8_2-linux-x64.sh
Installation method: Shell script installation
Download link: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Installation preparation:
(1) Check the installed JDK version of the system (the installed JDK version is OpenJDK):
[ root@centos7 ~]# java -version
openjdk version "1.8.0_65"
OpenJDK Runtime Environment (build 1.8.0_65-b17)
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)
(2) View the detailed information of the installed JDK:
[ root@centos7 ~]# rpm -qa | grep java
java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
tzdata-java-2015g-1.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64
java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
(3) Uninstall the installed OpenJDK:
[ root@centos7 ~]# rpm -e --nodeps tzdata-java-2015g-1.el7.noarch
[ root@centos7 ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64
[ root@centos7 ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64
[ root@centos7 ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
[ root@centos7 ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
installation steps:
(1) Download the latest JDK 64-bit version from the above-mentioned website in the Windows system.
(2) Use WinSCP tool to transfer the downloaded JDK file to the /usr/local folder of the CentOS system in the virtual machine.
(3) Enter the /usr/local folder and check the execution permissions of the jdk-8u111-nb-8_2-linux-x64.sh script:
[ root@centos7 ~]# cd /usr/local
[ root@centos7 local]# ls
bin games jdk-8u111-nb-8_2-linux-x64.sh lib64 sbin src
etc include lib libexec share
[ root@centos7 local]# ls -l
total 289396
drwxr-xr-x. 2 root root 4096 Aug 12 2015 bin
drwxr-xr-x. 2 root root 4096 Aug 12 2015 etc
drwxr-xr-x. 2 root root 4096 Aug 12 2015 games
drwxr-xr-x. 2 root root 4096 Aug 12 2015 include
(4) Increase the execution authority of the root user to the jdk-8u111-nb-8_2-linux-x64.sh file:
[ root@centos7 local]# chmod u+x jdk-8u111-nb-8_2-linux-x64.sh
[ root@centos7 local]# ls -l
total 289396
drwxr-xr-x. 2 root root 4096 Aug 12 2015 bin
drwxr-xr-x. 2 root root 4096 Aug 12 2015 etc
drwxr-xr-x. 2 root root 4096 Aug 12 2015 games
drwxr-xr-x. 2 root root 4096 Aug 12 2015 include
(5) Run the JDK shell script:
[ root@centos7 local]# ./jdk-8u111-nb-8_2-linux-x64.sh
Configuring the installer...
Searching for JVM on the system...
Preparing bundled JVM ...
Extracting installation data...
Running the installer wizard...
(6) Start the installation wizard:
(7) Configure system variables. Add the following system variables at the end of the /etc/profile file:
JAVA_HOME=/usr/local/jdk1.8.0_111
JRE_HOME=/usr/local/jdk1.8.0_111/jre
PATH=
export JAVA_HOME JRE_HOME PATH CLASSPATH
(8) Make the system variables in the file /etc/profile take effect (this time only takes effect temporarily, and the system variables will be automatically loaded next time the system starts to take effect permanently):
[ root@centos7 ~]# source /etc/profile
(9) Verify that the configuration is correct:
[ root@centos7 ~]# echo $PATH
/usr/local/jdk1.8.0_111/bin:/usr/local/jdk1.8.0_111/jre/bin:/usr/lib64/qt3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/root/bin
[ root@centos7 ~]# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
Recommended Posts