目標:將jdk安裝到usr/java/jdk 目錄下java
我是在window上去jdk官網下載jdk安裝包,我下的是:jdk-8u221-linux-x64.tar.gz。原本在centos中能夠經過 wget jdk地址 來下載,我這個下載太慢了,只能在windows中下載好,而後經過rz命令上傳到centos中,目錄以下
[root@43-c59438365-0048-0727982 jdk]# pwd
/usr/java/jdk
[root@43-c59438365-0048-0727982 jdk]# ll
total 190716
-rw-r--r-- 1 root root 195094741 Jul 23 17:50 jdk-8u221-linux-x64.tar.gz
[root@43-c59438365-0048-0727982 jdk]#linux
[root@43-c59438365-0048-0727982 jdk]# tar -zxvf jdk-8u171-linux-x64.tar.gz
[root@43-c59438365-0048-0727982 jdk]# ll
total 190720
drwxr-xr-x 7 10 143 4096 Jul 4 19:37 jdk1.8.0_221
-rw-r--r-- 1 root root 195094741 Jul 23 17:50 jdk-8u221-linux-x64.tar.gz
[root@43-c59438365-0048-0727982 jdk]# cd jdk1.8.0_221/
[root@43-c59438365-0048-0727982 jdk1.8.0_221]# pwd
/usr/java/jdk/jdk1.8.0_221windows
[root@43-c59438365-0048-0727982 jdk1.8.0_221]# cd /etc
[root@43-c59438365-0048-0727982 etc]# vi profile
在結尾處加上以下配置
unset i
unset -f pathmunge
#) jdk環境變量配置
JAVA_HOME=/usr/java/jdk/jdk1.8.0_221
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
#)
TMOUT=1800
readonly TMOUT
export TMOUTcentos
[root@43-c59438365-0048-0727982 etc]# java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
[root@43-c59438365-0048-0727982 etc]#ui
至此結束。get