CentOS7 下安装 Java 8 [wget]

1. 创建一个文件夹

sudo mkdir /usr/local/services/java8 

2. 使用 wget 来下载

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz"

3. 解压 [tar]命令教程

tar xzf jdk-8u161-linux-x64.tar.gz

4. 安装 Java

alternatives --install /usr/bin/java java /usr/local/services/java8/jdk1.8.0_161/bin/java 2

alternatives --config java

5. 安装 jar 和 javac 命令

alternatives --install /usr/bin/jar jar /usr/local/services/java8/jdk1.8.0_161/bin/jar 2
alternatives --install /usr/bin/javac javac /usr/local/services/java8/jdk1.8.0_161/bin/javac 2
alternatives --set jar /usr/local/services/java8/jdk1.8.0_161/bin/jar
alternatives --set javac /usr/local/services/java8/jdk1.8.0_161/bin/javac

6. 测试 java -version

 

posted @ 2018-03-31 18:32  zacky31  阅读(8759)  评论(0编辑  收藏  举报