记一次java-11的安装
1. yum源搜索java-11的安装包
yum search java-11
输出:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
=========================================================== N/S matched: java-11 ============================================================
java-11-openjdk.i686 : OpenJDK Runtime Environment 11
java-11-openjdk.x86_64 : OpenJDK 11 Runtime Environment
java-11-openjdk-demo.i686 : OpenJDK Demos 11
java-11-openjdk-demo.x86_64 : OpenJDK 11 Demos
java-11-openjdk-devel.i686 : OpenJDK Development Environment 11
java-11-openjdk-devel.x86_64 : OpenJDK 11 Development Environment
java-11-openjdk-headless.i686 : OpenJDK Headless Runtime Environment 11
java-11-openjdk-headless.x86_64 : OpenJDK 11 Headless Runtime Environment
java-11-openjdk-javadoc.i686 : OpenJDK 11 API documentation
java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentation
java-11-openjdk-javadoc-zip.i686 : OpenJDK 11 API documentation compressed in a single archive
java-11-openjdk-javadoc-zip.x86_64 : OpenJDK 11 API documentation compressed in a single archive
java-11-openjdk-jmods.i686 : JMods for OpenJDK 11
java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11
java-11-openjdk-src.i686 : OpenJDK Source Bundle 11
java-11-openjdk-src.x86_64 : OpenJDK 11 Source Bundle
java-11-openjdk-static-libs.i686 : OpenJDK libraries for static linking 11
java-11-openjdk-static-libs.x86_64 : OpenJDK 11 libraries for static linking
Name and summary matches only, use "search all" for everything.
2. 安装(我这里就直接安装全部了)
yum install java-11* -y
3. 验证安装结果
java -version
输出:
openjdk version "11.0.11" 2021-04-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.11+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9-LTS, mixed mode, sharing)
4. 查看安装的目录,并设置JAVA_HOME
[root@python ~]# whereis java
java: /usr/bin/java /usr/lib/java /etc/java /usr/share/java /usr/share/man/man1/java.1.gz
[root@python ~]# ll -a /usr/bin/java
lrwxrwxrwx 1 root root 22 May 10 22:29 /usr/bin/java -> /etc/alternatives/java
[root@python ~]# ll -a /etc/alternatives/java
lrwxrwxrwx 1 root root 64 May 10 22:29 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64/bin/java
java-11的安装本地目录位:/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64/bin/java
设置JAVA_HOME
编辑文件/etc/profile
vi /etc/profile
在文件的最末位添加如下并保存文件
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64
export PATH=$JAVA_HOME/bin:$PATH
使环境变量生效:
source /etc/profile