Liunx 安装JDK1.8
1.准备工作
- 创建文件夹,进入安装目录
cd /usr/local# 创建jdk目录mkdir jdk# 进入目录cd jdk
- 在线下载
//下载命令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"//解压命令tar xzf jdk-8u141-linux-x64.tar.gz//可以将两个命令合在一起使用得到一个压缩包和一个解压好的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"tar xzf jdk-8u141-linux-x64.tar.gz
- 离线下载(官网下载链接)
https://www.oracle.com/java/technologies/downloads/#java8
2.配置
- 配置JDK的环境变量,vim /etc/profile。添加下边的语句:(注意JAVA_HOME、JRE_HOME要对应JDK保存的位置):
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_141export JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:JAVAHOME/lib:{JRE_HOME}/lib:$CLASSPATHexport JAVA_PATH=${JAVAHOME}/bin:${JRE_HOME}/binexport PATH=$PATH:${JAVA_PATH}
- 使配置文件立即生效,source /etc/profile
- 查看环境变量是否配置成功:java -version。(出现版本号,说明配置成功了)
[root@ali_server temp]# java -versionjava 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)
来源地址:https://blog.csdn.net/weixin_45248225/article/details/128706553