本文主要說明了在centos7系統(tǒng)下安裝JDK8的詳細步驟
- 1.1 下載jdk8
下載jdk8 -
1.2 把下載好的jdk8包傳輸?shù)絚entos7服務器
- 1.3 解壓
tar -xvf jdk-8u241-linux-i586.tar.gz
用ll
命令查看解壓后的文件
[root@iZipqoqa9axzz1Z java]# ll
total 190576
drwxr-xr-x 7 10143 10143 4096 Dec 11 18:52 jdk1.8.0_241
-rw-r--r-- 1 root root 195143852 Mar 30 16:56 jdk-8u241-linux-i586.tar.gz
[root@iZipqoqa9axzz1Z java]#
刪除安裝包rm -rf jdk-8u241-linux-i586.tar.gz
(刪除時輸入 jdk-后,再按Tab鍵自動補全jdk安裝包名字)
刪除后查看目錄:
[root@iZipqoqa9axzz1Z java]# ll
total 4
drwxr-xr-x 7 10143 10143 4096 Dec 11 18:52 jdk1.8.0_241
- 1.4 用vim編輯器設(shè)置jdk8的環(huán)境變量
vim /etc/profile
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
- 1,5 輸入 i 鍵闸衫,切換到編輯模式(注:在最下方出現(xiàn) --INSERT-- 才表示進入到編輯模式)
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
-- INSERT -- 78,1 Bot
移動光標在最下方填上:
JAVA_HOME=/fcj/java/jdk1.8.0_241
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
- 1.6 輸入
Esc
退出vim編輯模式米辐,再按:wq+回車
(保存并退出) - 1.7 輸入
source /etc/profile
使環(huán)境變量文件立即生效 - 1.8 用 java -version 命令查看JDK是否安裝成功
[root@iZipqoqa9axzz1Z java]# java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) Server VM (build 25.241-b07, mixed mode)
[root@iZipqoqa9axzz1Z java]#