在 CentOS 系统下,您可以通过以下步骤安装 Java Development Kit (JDK):
首先,打开终端。
添加 CentOS 的官方仓库。创建一个新文件 /etc/yum.repos.d/CentOS-Base.repo
,然后将以下内容粘贴到文件中:
[base]
name=CentOS-$releasever - Base
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official
保存文件并退出。
sudo yum clean all
sudo yum update
sudo yum install java-1.8.0-openjdk-devel
java -version
如果安装成功,您将看到类似于以下的输出:
openjdk version "1.8.0_291"
OpenJDK Runtime Environment (build 1.8.0_291-b10)
OpenJDK 64-Bit Server VM (build 25.291-b10, mixed mode)
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: centos防火墙策略怎么配置