centos安装java11
时间: 2023-06-17 18:07:12 浏览: 125
Centos配置java环境
以下是在CentOS上安装Java 11的步骤:
1.首先,使用以下命令更新系统软件包:
```
sudo yum update
```
2.安装OpenJDK 11:
```
sudo yum install java-11-openjdk-devel
```
3.检查Java版本:
```
java -version
```
如果成功安装,您应该可以看到以下输出:
```
openjdk version "11.0.10" 2021-01-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.10+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9-LTS, mixed mode, sharing)
```
4.设置JAVA_HOME环境变量:
```
echo "export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac)))))" | sudo tee -a /etc/profile
```
5.使环境变量生效:
```
source /etc/profile
```
6.最后,您可以检查JAVA_HOME环境变量是否正确设置:
```
echo $JAVA_HOME
```
如果正确设置,您应该看到以下输出:
```
/usr/lib/jvm/java-11-openjdk-11.0.10.0.9-1.el8_3.x86_64
```
现在,您已经成功在CentOS上安装了Java 11。
阅读全文