一、下載jdk:
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz
或者
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn/java/jdk/8u221-b11/230deb18db3e4014bb8e3e8324f81b43/jdk-8u221-linux-x64.tar.gzjava
rpm下載:
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
rpm 安裝方法:rpm -ivh xxxx.rpm
二、解壓
tar -zxvf jdk-8u151-linux-x64.tar.gz
三、配置
配置java環境變量
編輯系統環境變量linux
vi /etc/profilecookie
輸入ioracle
加入內容以下:3d
export JAVA_HOME=/usr/local/jdk1.7.0_71 #bin的上一級
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATHblog
而後重啓profile :source /etc/profile
若是沒法運行java命令的話,報如下錯誤get
須要執行,yum install coreutilsio
再source /etc/profilecookies
若是有openjdk的話,先卸載變量
2.rpm -qa | grep java
3.卸載