CentOS 7 JDK8安裝與配置【備忘】
阿新 • • 發佈:2018-12-17
【寫在前面】如果看完這篇部落格,對你有幫助的話,歡迎加入全棧技術交流群,群內不定時釋出熱門學習資料,也歡迎進行技術交流,對我的部落格有疑問也可以在群裡@我。《全棧技術交流群歡迎你》
[[email protected] home]# rpm -ivh jdk-8u172-linux-x64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:jdk1.8-2000:1.8.0_172-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
[ [email protected] home]# java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
[[email protected] home]#
找到jdk路徑
[[email protected] home]#
[[email protected] home]# ls -lrt /usr/bin/java
lrwxrwxrwx. 1 root root 22 Dec 6 09:43 /usr/bin/java -> /etc/alternatives/java
[ [email protected] home]# ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 41 Dec 6 09:43 /etc/alternatives/java -> /usr/java/jdk1.8.0_172-amd64/jre/bin/java
[[email protected] home]#
修改profile檔案
[[email protected] bin]# vi /etc/profile
在profile檔案開頭或末尾加入
export JAVA_HOME=/usr/java/jdk1.8.0_172-amd64 export JRE_HOME=/usr/java/jdk1.8.0_172-amd64/jre export PATH=PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
使檔案生效
[[email protected] bin]# source /etc/profile
確認配置
[[email protected] home]# echo $JAVA_HOME
/usr/java/jdk1.8.0_172-amd64
[[email protected] home]# echo $PATH
PATH=/usr/java/jdk1.8.0_172-amd64/bin:/usr/java/jdk1.8.0_172-amd64/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[[email protected] home]#