1、下载 java 包
wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz

yum/wget 下载慢操作步骤:

  • 首先备份系统自带『yum 源配置文件』,具体路径为:/etc/yum.repos.d/CentOS-Base.repo
  • mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
    
  • 下载阿里云的 yum 源配置文件到文件夹『/etc/yum.repos.d/』中。
# 各系统版本repo文件对应的下载操作 
# CentOS 5 
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo 
 
# CentOS 6 
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 
 
# CentOS 7 
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  • 清除 yum 缓存:yum clean all
  • 生成新的缓存:yum makecache
2、解压
mkdir /usr/local/java
tar -zxvf jdk-17_linux-x64_bin.tar.gz -C /usr/local/java
3、配置环境变量
echo 'export PATH=$PATH:/usr/local/java/jdk-17.0.9/bin' >> /etc/profile && source /etc/profile
4、验证
[root@k8s-4-m1 java]# java --version
java 17.0.9 2023-10-17 LTS
Java(TM) SE Runtime Environment (build 17.0.9+11-LTS-201)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.9+11-LTS-201, mixed mode, sharing)
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐