查看JDK的安装路径
# java -version
============================
查看Linux系统版本信息
# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@li409-225 ~]# cat /etc/issue
CentOS release 6.9 (Final)
Kernel \r on an \m
============================
centos6或centos7都可用的 yum安装jdk
安装之前先检查一下系统有没有自带open-jdk
命令:
rpm -qa |grep java
rpm -qa |grep jdk
rpm -qa |grep gcj
如果没有输入信息表示没有安装。
如果安装可以使用
rpm -qa | grep java | xargs rpm -e --nodeps
批量卸载所有带有Java的文件 这句命令的关键字是java
检索包含java的列表(可跳过此步):
yum list java*
检索1.8的列表:
yum list java-1.8*
安装1.8.0的所有文件:
yum install java-1.8.0-openjdk* -y
出现 Complete!表示安装完成
使用命令检查是否安装成功:
#java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
不需要对path进行手动设置,已自动设置好了
yum install 了之后,java 是默认下载到 /usr/lib/jvm/ 这个目录下。
# find / -name 'java'
/var/lib/alternatives/java
/etc/pki/ca-trust/extracted/java
/etc/pki/java
/etc/alternatives/java
/etc/java
/root/sphinx-for-chinese-2.2.1-dev-r4311/api/java
/usr/share/javadoc/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9/jre/api/plugin/dom/com/sun/java
/usr/share/javadoc/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9/jre/api/accessibility/jaccess/spec/com/sun/java
/usr/share/javadoc/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9/api/org/omg/stub/java
/usr/share/javadoc/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9/api/java
/usr/share/javadoc/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9-debug/jre/api/plugin/dom/com/sun/java
/usr/share/javadoc/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9-debug/jre/api/accessibility/jaccess/spec/com/sun/java
/usr/share/javadoc/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9-debug/api/org/omg/stub/java
/usr/share/javadoc/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9-debug/api/java
/usr/share/javadoc/java
/usr/share/doc/db4-devel-4.7.25/ref/java
/usr/share/doc/db4-devel-4.7.25/java
/usr/share/java
/usr/bin/java
/usr/lib/jvm-exports/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9.x86_64-debug/jre/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9.x86_64-debug/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9.x86_64/jre/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9.x86_64/bin/java
/usr/lib/jvm/java
/usr/lib/java
---------------------
其中启动命令需要用到的两个是:
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9.x86_64/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9.x86_64/jre/lib/ext