1. 下载 java
离线下载
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/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"
转载自: https://blog.csdn.net/dandan920107/article/details/94398465
2. 解压
将下载的 jdk-8u141-linux-x64.tar.gz 拷贝致 opt 目录
mkdir /opt/java/ cd /opt/ tar -zxvf jdk-8u141-linux-x64.tar.gz -C java
3. 创建软连接
cd /bin sudo ln -s /opt/jdk1.8.0_141/bin/java java
3. 配置环境变量
sudo vi /etc/profile
在最后加入
export JAVA_HOME=/opt/java/jdk1.8.0_141 export PATH=${JAVA_HOME}/bin:${PATH}
保存退出, 最后使之生效
source /etc/profile
4. 验证
java -version
结果:
java version "1.8.0_141" Java(TM) SE Runtime Environment (build 1.8.0_141-b15) Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
附录:下面看下wget下载java8离线安装包 for linux
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/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz”
总结
到此这篇关于Ubuntu 16.04 安装 java 8的方法的文章就介绍到这了,更多相关Ubuntu 16.04 安装 java 8内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!