Linux下如何查看JDK安装路径

时间:2021-01-14 19:44:06

1:echo $JAVA_HOME

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

[root@localhost ~]# java -version

java version "1.7.0_65"

OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-x86_64 u65-b17)

OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

[root@localhost ~]# echo $JAVA_HOME

Linux下如何查看JDK安装路径

2:which java

首先要申明一下which java是定位不到安装路径的。which java定位到的是java程序的执行路径。那么怎么定位到java的安装路径呢?下面我们来看看例子吧,如下所示:

[root@localhost ~]# java -version
java version "1.7.0_51"
OpenJDK Runtime Environment (rhel-2.4.5.5.el7-x86_64 u51-b31)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
[root@localhost ~]# which java
/usr/bin/java
[root@localhost ~]# ls -lrt /usr/bin/java
lrwxrwxrwx. 1 root root 22 9月 6 22:51 /usr/bin/java -> /etc/alternatives/java
[root@localhost ~]# ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 72 9月 6 22:51 /etc/alternatives/java -> /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64/jre/bin/java

  

Linux下如何查看JDK安装路径

参考:http://www.cnblogs.com/kerrycode/archive/2015/08/27/4762921.html