CentOS8安装Java
时间: 2024-10-23 18:01:34 浏览: 17
在CentOS 8上安装Java(Java Development Kit,简称JDK),通常你可以按照以下步骤操作:
1. **更新系统**:
```sh
sudo yum update -y
```
2. **添加EPEL仓库**(如果尚未安装):
对于旧版本的CentOS 8,可以使用:
```sh
sudo curl -o /etc/yum.repos.d/epel.repo https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/epel-release-7-15.noarch.rpm
```
如果是CentOS 8 Stream,则使用:
```sh
sudo curl -o /etc/yum.repos.d/epel-stream-release-latest-8.noarch.rpm https://mirrors.tuna.tsinghua.edu.cn/epel-stream/8/Everything/x86_64/epel-stream-release-latest-8.noarch.rpm
```
然后运行:
```sh
sudo yum install epel-release -y
```
3. **安装Java JDK**:
使用`epel`仓库提供最新版本的Java,你可以选择安装OpenJDK:
```sh
sudo yum install java-1.8.0-openjdk-devel -y
```
或者安装Oracle JDK:
```sh
sudo yum install java-8u312-openjdk-devel -y # 替换为你需要的具体版本号
```
4. **验证安装**:
```sh
java -version
```
阅读全文