Linux如何查看JDK的安装路径 --转

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux如何查看JDK的安装路径 --转相关的知识,希望对你有一定的参考价值。

如何在一台Linux服务器上查找JDK的安装路径呢? 有那些方法可以查找定位JDK的安装路径?是否有一些局限性呢? 下面总结了一下如何查找JDK安装路径的方法。

1:echo $JAVA_HOME

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

[[email protected] ~]# 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)

[[email protected] ~]# echo $JAVA_HOME

技术分享

2:which java

首先要申明一下which java是定位不到安装路径的。which java定位到的是java程序的执行路径。网上的资料都是人云亦云,完全不去思考。那么怎么定位到java的安装路径呢?下面我们来看看例子吧,如下所示:

[[email protected] ~]# 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)
 
[[email protected] ~]# which java
 
/usr/bin/java
 
[[email protected] ~]# ls -lrt /usr/bin/java
 
lrwxrwxrwx. 1 root root 22 Aug 17 15:12 /usr/bin/java -> /etc/alternatives/java
 
[[email protected] ~]# ls -lrt /etc/alternatives/java
 
lrwxrwxrwx. 1 root root 46 Aug 17 15:12 /etc/alternatives/java -> /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
 
[[email protected] ~]# 
 
[[email protected] ~]# cd /usr/lib/jvm
 
[[email protected] jvm]# ls
 
java-1.6.0-openjdk-1.6.0.0.x86_64 java-1.7.0-openjdk-1.7.0.65.x86_64 jre jre-1.6.0 jre-1.6.0-openjdk.x86_64 jre-1.7.0 jre-1.7.0-openjdk.x86_64 jre-openjdk
 
[[email protected] jvm]#

技术分享

whereis java 也是如此,它本身不能定位到安装路径。可以通过上面例子去定位安装路径

技术分享

3: rpm -ql packagename

如果JDK是源码安装的话,那么这个方法也是行不通的。也就是说rpm –ql packagename也是有一定局限性的。

[[email protected] ~]# 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)
[[email protected] ~]# rpm -qa | grep java
tzdata-java-2014g-1.el6.noarch
java-1.6.0-openjdk-1.6.0.0-11.1.13.4.el6.x86_64
java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el6_5.x86_64
[[email protected] ~]# rpm -ql java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el6_5.x86_64 | more
/etc/.java
/etc/.java/.systemPrefs
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jaas-1.7.0.65.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jaas-1.7.0.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jaas.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jce-1.7.0.65.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jce-1.7.0.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jce.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jdbc-stdext-1.7.0.65.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jdbc-stdext-1.7.0.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jdbc-stdext-3.0.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jdbc-stdext.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-1.7.0.65.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-1.7.0.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-cos-1.7.0.65.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-cos-1.7.0.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-cos.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-ldap-1.7.0.65.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-ldap-1.7.0.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-ldap.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-rmi-1.7.0.65.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-rmi-1.7.0.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi-rmi.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jndi.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jsse-1.7.0.65.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jsse-1.7.0.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/jsse.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/sasl-1.7.0.65.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/sasl-1.7.0.jar
/usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.65.x86_64/sasl.jar
/usr/lib/jvm-exports/jre-1.7.0-openjdk.x86_64
/usr/lib/jvm-private/java-1.7.0-openjdk.x86_64
/usr/lib/jvm-private/java-1.7.0-openjdk.x86_64/jce
/usr/lib/jvm-private/java-1.7.0-openjdk.x86_64/jce/vanilla
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/ASSEMBLY_EXCEPTION
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/LICENSE
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/THIRD_PARTY_README
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/bin
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/bin/java
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/bin/keytool
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/bin/orbd
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/bin/pack200
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/bin/policytool
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/bin/rmid
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/bin/rmiregistry
--More--

技术分享

CentOS 搭建JDK环境  http://www.linuxidc.com/Linux/2015-06/118879.htm

Ubuntu 14.04安装JDK1.8.0_25与配置环境变量  http://www.linuxidc.com/Linux/2015-01/112030.htm

Ubuntu 14.04 LTS安装Oracle JDK 1.8  http://www.linuxidc.com/Linux/2014-11/109216.htm

CentOS6.3安装JDK和环境配置 http://www.linuxidc.com/Linux/2012-09/70780.htm

Ubuntu 14.04 安装 JDK8  http://www.linuxidc.com/Linux/2014-09/106218.htm

Ubuntu下安装JDK图文解析 http://www.linuxidc.com/Linux/2014-09/107291.htm

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-08/122353.htm






















































































以上是关于Linux如何查看JDK的安装路径 --转的主要内容,如果未能解决你的问题,请参考以下文章

097_linux如何配置jdk路径

请问linux 中如何设置环境变量?在哪个文件下可以查看该环境变量。

linux如何指定非环境变量的jdk运行jar包

linux 下如何启动SVN服务。

如何获取linux进程的执行文件路径

Tomcat指定JDK路径(Linux+Windows)