Centos:如何查找安装的jdk的目录

使用$JAVA_HOME的话能定位JDK的安装路径的前提是配置了环境变量$JAVA_HOME,否则如下所示,根本定位不到JDK的安装路径。

正确的方式是通过 which java:

[tt@vddd conf]$ java -version
openjdk version "1.8.0_65"
OpenJDK Runtime Environment (build 1.8.0_65-b17)
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)
[tt@vddd conf]$ echo $JAVA_HOME

[tt@vddd conf]$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/app/tt/.local/bin:/app/tt/bin
[tt@vddd conf]$ whereis java
java: /usr/bin/java /usr/lib/java /etc/java /usr/share/java /usr/share/man/man1/java.1.gz
[tt@vddd conf]$ which java
/usr/bin/java
[tt@vddd conf]$ cd /usr/bin/java
-bash: cd: /usr/bin/java: Not a directory
[tt@vddd conf]$ ls -lrt /usr/bin/java
lrwxrwxrwx. 1 root root 22 Oct 18 11:19 /usr/bin/java -> /etc/alternatives/java
[tt@vddd conf]$  ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 70 Oct 18 11:19 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre/bin/java
[tt@vddd conf]$ cd /usr/lib/jvm
[tt@vddd jvm]$ ls
java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64  jre-1.7.0                                      jre-1.8.0                                    jre-openjdk
java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64    jre-1.7.0-openjdk                              jre-1.8.0-openjdk
jre                                             jre-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64  jre-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
[tt@vddd jvm]$ 

 

posted @ 2017-03-08 15:25  cctext  阅读(2092)  评论(0编辑  收藏  举报