- 查看Linux是否自带的JDK,如有openJDK,则卸载
1 java -version
1 rpm -qa | grep -E '^open[jre|jdk]|j[re|dk]'
- 卸载openjdk
1 su root 2 3 yum -y remove java java-1.7.0-openjdk
- 下载oracle jdk
1 wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz"
- 解压jdk
1 tar -xzvf jdk-8u77-linux-x64.tar.gz
- 移动jdk到/usr/local,建立软连接
1 mv jdk1.8.0_77/ /usr/local
2
3 ln -s /usr/local/jdk1.8.0_77/ /usr/local/jdk
- 编辑/etc/profile
1 vim /etc/profile
- 加入jdk的配置
1 JAVA_HOME=/usr/local/jdk 2 PATH=${PATH}:${JAVA_HOME}/bin 3 export JAVA_HOME PATH
- source
1 source /etc/profile
- 查看是否安装jdk成功
1 java -version