下載地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htmlhtml
root權限登錄java
查看U盤node
[root@localhost admin]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 16G 35G 31% /
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 3.0G 1.6G 1.5G 51% /dev/shm
tmpfs 1.9G 9.1M 1.8G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 494M 227M 267M 46% /boot
/dev/mapper/centos-home 412G 358M 411G 1% /home
tmpfs 370M 28K 370M 1% /run/user/1001
/dev/sdb4 15G 2.8G 12G 19% /run/media/oracle/LWJ
紅色標示爲個人U盤python
新建U盤掛載點linux
[root@localhost admin]# mkdir /mnt/usb
掛載U盤vim
[root@localhost admin]# mount /dev/sdb4 /mnt/usb
將JDK文件夾下的安裝包拷貝到系統文件夾下centos
[root@localhost admin]# cp –r /mnt/usb/JDK/* /usr/java
解壓縮文件到當前文件夾oracle
[root@localhost admin]# tar –zxf jdk-8u161-linux-x64.tar.gz
重命名app
[root@localhost admin]# mv jdk1.8.0_161 jdk1.8
[root@localhost admin]# java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
[root@localhost admin]# rpm -qa | grep java
java-1.7.0-openjdk-1.7.0.141-2.6.10.5.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.131-11.b12.el7.x86_64
tzdata-java-2017b-1.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64
python-javapackages-3.4.1-11.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.141-2.6.10.5.el7.x86_64
[root@localhost admin]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.141-2.6.10.5.el7.x86_64
[root@localhost admin]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.131-11.b12.el7.x86_64
[root@localhost admin]# rpm -e --nodeps tzdata-java-2017b-1.el7.noarch
[root@localhost admin]# rpm -e --nodeps javapackages-tools-3.4.1-11.el7.noarch
[root@localhost admin]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64
[root@localhost admin]# rpm -e --nodeps python-javapackages-3.4.1-11.el7.noarch
[root@localhost admin]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.141-2.6.10.5.el7.x86_64
[root@localhost admin]# vim /etc/profile
命令打開配置文件,在末尾添加如下內容:less
#Path JDK1.8
JAVA_HOME=/usr/java/jdk1.8
JRE_HOME=/usr/java/jdk1.8/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
ESC退出編輯,(:wq)保存並退出。
[root@localhost admin]# source /etc/profile
[root@localhost admin]# java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
[root@localhost admin]#
至此安裝完成