linux wget安装jdk
1、下载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.gz
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
2、解压
tar -zxvf jdk-8u151-linux-x64.tar.gz
3、配置
配置java环境变量
编辑系统环境变量
vi /etc/profile
输入i
加入内容如下:
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:$PATH
然后重启profile :source /etc/profile
如果无法运行java命令的话,报以下错误
需要执行,yum install coreutils
再source /etc/profile
如果有openjdk的话,先卸载
2.rpm -qa | grep java
3.卸载