Linux CentOS下安装JDK
程序员文章站
2023-11-07 12:15:34
本文讲解如何在Linux CentOS下,下载安装JDK 环境: Linux CentOS 本文实践内容,使用阿里云ECS,通过XShell客户端连接阿里云服务器操作实现。读者也可以在自己PC机,或服务器Linux操作系统下,完成JDK下载安装操作。 1、下载JDK 从网上,搜索到一个指令,但是有问 ......
本文讲解如何在Linux CentOS下,下载安装JDK
环境:
Linux CentOS
本文实践内容,使用阿里云ECS,通过XShell客户端连接阿里云服务器操作实现。读者也可以在自己PC机,或服务器Linux操作系统下,完成JDK下载安装操作。
1、下载JDK
从网上,搜索到一个指令,但是有问题,报“404 not found”,需要将下载jdk的url修改一下,就可以了
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u171-linux-x64.tar.gz
如上这个 url 有问题,将最后的 链接替换下,从oracle的官网查找最新jdk的url
鼠标,右键——“复制链接地址”
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
可以成功的下载:
Linux终端显示:
1 [root@izuf6famz0x92jd98na1kiz download]# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz 2 --2018-07-04 14:09:57-- http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz 3 Resolving download.oracle.com (download.oracle.com)... 104.127.201.249 4 Connecting to download.oracle.com (download.oracle.com)|104.127.201.249|:80... connected. 5 HTTP request sent, awaiting response... 302 Moved Temporarily 6 Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz [following] 7 --2018-07-04 14:09:57-- https://edelivery.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz 8 Resolving edelivery.oracle.com (edelivery.oracle.com)... 184.26.250.202, 2600:1417:76:19a::2d3e, 2600:1417:76:181::2d3e 9 Connecting to edelivery.oracle.com (edelivery.oracle.com)|184.26.250.202|:443... connected. 10 HTTP request sent, awaiting response... 302 Moved Temporarily 11 Location: http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1530684717_3a28246d3478a7373e7ff2e35b8998ad [following] 12 --2018-07-04 14:09:58-- http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1530684717_3a28246d3478a7373e7ff2e35b8998ad 13 Connecting to download.oracle.com (download.oracle.com)|104.127.201.249|:80... connected. 14 HTTP request sent, awaiting response... 200 OK 15 Length: 190890122 (182M) [application/x-gzip] 16 Saving to: ‘jdk-8u171-linux-x64.tar.gz’ 17 18 100%[=========================================================================================================================================>] 190,890,122 3.17MB/s in 31s 19 20 2018-07-04 14:10:29 (5.90 MB/s) - ‘jdk-8u171-linux-x64.tar.gz’ saved [190890122/190890122]
查看下载后的目录
2、创建目录
mkdir /usr/java
把下载的 jdk-8u171-linux-x64.tar.gz 放进这个目录
mv jdk-8u171-linux-x64.tar.gz /usr/java
3、解压缩
tar -zxvf jdk-8u171-linux-x64.tar.gz
自动解压
解压后会在Java文件夹下产生一个jdk1.8.0_171目录
4、定义JAVA_HOME的环境变量目录
打开 /etc/profile 文件
vi /etc/profile
在其中,定义 java的环境变量
set java environment JAVA_HOME=/usr/java/jdk1.8.0_171 CLASSPATH=$JAVA_HOME/lib/ PATH=$PATH:$JAVA_HOME/bin export JAVA_HOME CLASSPATH PATH
保存并执行,让修改生效
source /etc/profile
5、检测jdk安装成功与否
echo $JAVA_HOME
或者
java -version
JDK配置完成。
Donate捐赠
如果我的文章帮助了你,可以赞赏我 1 元,让我继续写出更好的内容)
(微信) (支付宝)
微信/支付宝 扫一扫
上一篇: 秋季肝火旺怎么办? 九种果蔬清热降肝火