CentOS7源码安装jdk11
1.下载jdk
如有旧版本请先卸载openjdk:
[root@localhost ~]# yum erase `rpm -qa | grep openjdk` -y
2.解压安装
[root@localhost ~]# tar -xvf jdk-11.0.16.1_linux-x64_bin.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ll jdk-11.0.16.1
3.修改环境变量
[root@localhost ~]# vim /etc/profile #jdk-11.0.16.1 export JAVA_HOME=/usr/local/jdk-11.0.16.1 export PATH=$PATH:$JAVA_HOME/bin [root@localhost ~]# source /etc/profile
4.查看java版本
[root@localhost ~]# java -version java version "11.0.16.1" 2022-08-18 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.16.1+1-LTS-1) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.16.1+1-LTS-1, mixed mode)