http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htmlhtml
我選擇linux x64版本:java
wget http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1531155951_4e06a4d17c6c1dbfb8440352e19dd2ae
該下載地址已失效 請自行在官網複製下載地址linux
下載之後經過命令檢查安裝包大小是否符合shell
ls -lht
(1)建立安裝目錄vim
mkdir /usr/local/java/
(2)解壓至安裝目錄oracle
tar -zxvf jdk-8u171-linux-x64.tar.gz -C /usr/local/java/
打開文件url
vim /etc/profile
在末尾添加code
export JAVA_HOME=/usr/local/java/jdk1.8.0_171 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
使環境變量生效htm
source /etc/profile
添加軟連接blog
ln -s /usr/local/java/jdk1.8.0_171/bin/java /usr/bin/java
檢查
java -version