Linux下如何查看JDK安装路径
程序员文章站
2022-06-29 08:45:02
...
1:echo $JAVA_HOME
使用$ JAVA_HOME的话能定位JDK的安装路径的前提是配置了环境变量$JAVA_HOME,否则如下所示,根本定位不到JDK的安装路径
[aaa@qq.com ~]# 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)
[aaa@qq.com ~]# echo $JAVA_HOME
2:which java
首先要申明一下which java是定位不到安装路径的。which java定位到的是java程序的执行路径。那么怎么定位到java的安装路径呢?下面我们来看看例子吧,如下所示:
[aaa@qq.com ~]# 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)
[aaa@qq.com ~]# which java
/usr/bin/java
[aaa@qq.com ~]# ls -lrt /usr/bin/java
lrwxrwxrwx. 1 root root 22 9月 6 22:51 /usr/bin/java -> /etc/alternatives/java
[aaa@qq.com ~]# 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