JAVA 11 RPM安装

JAVA 11 RPM安装

  1. 检查openjdk版本,需要jdk11的版本
rpm -qa | grep jdk
  1. 卸载相关其他版本
rpm -e --nodeps java-x.x.x-openjdk-headless-1.7.0.111-2.6.7.2.el7_2.x86_64 
  1. 再次检查openjdk所有版本是否卸载完毕
rpm -qa | grep jdk
  1. 查询JAVA RPM安装包(版本11)
yum search java-11 | grep -i --color JDK
  1. 安装JAVA RPM包
yum install -y java-11-openjdk.x86_64 java-11-openjdk-devel.x86_64
  1. 查看JAVA rpm包安装目录
ls -l /usr/lib/jvm
  1. 设置环境变量(一次性生效,仅针对当前用户)
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64
  1. 设置环境变量(永久生效针对系统所有用户)
vim /etc/profile
  1. 在末尾添加(重点是:JAVA_HOME目录设置正确)
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
  1. 使profile配置文件生效
source /etc/profile
  1. 验证java是否安装成功
java --version
openjdk 11.0.1 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
a. echo $JAVA_HOME
    /usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64
b. echo $CLASSPATH
    .:/usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64/lib/dt.jar:/usr/lib/jvm/java-11-          openjdk-11.0.3.7-0.el7_6.x86_64/lib/tools.jar
c. echo $PATH
    /usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/bin:/root/.py3/bin:/usr/local/jdk/bin:/usr/local/jdk/jre/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/opennms/bin:/root/bin

你可能感兴趣的:(JAVA 11 RPM安装)