centos openjdk安装
查询安装的jdk
[root@VM-24-3-centos ~]# rpm -qa | grep java java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el7_9.x86_64 tzdata-java-2021e-1.el7.noarch javapackages-tools-3.4.1-11.el7.noarch python-javapackages-3.4.1-11.el7.noarch |
卸载安装的jdk
[root@VM-24-3-centos ~]# yum -y remove java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el7_9.x86_64 |
安装openjdk
yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel |
查看位置
[root@iZm5ee1mp8u5k7ze0hbzzjZ jdk]# dirname $(readlink $(readlink $(which java))) /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/jre/bin |
设置环境变量
vim /etc/profile.d/env_export.sh |
添加如下内容
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64 JRE_HOME=$JAVA_HOME/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH |
刷新环境变量
source /etc/profile.d/env_export.sh |
查看
java -version |
windows openjdk安装
下载地址 http://jdk.java.net/16/
解压后
配置环境变量
PATH E:\install\jdk-16.0.1\bin
JAVA_HOME E:\install\jdk-16.0.1
查看
C:\Users\Administrator>java -version
openjdk version “16.0.1” 2021-04-20
OpenJDK Runtime Environment (build 16.0.1+9-24)
OpenJDK 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)