您好,登錄后才能下訂單哦!
本篇內容主要講解“linux如何查看jdk安裝路徑”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“linux如何查看jdk安裝路徑”吧!
linux查看jdk安裝路徑的方法:1、使用“echo $JAVA_HOME”命令,可獲取環境變量“$JAVA_HOME”配置的jdk路徑;2、使用“rpm -qa | grep java”命令,通過獲取安裝包的路徑來查看jdk安裝路徑。
本教程操作環境:linux5.9.8系統、Dell G3電腦。
linux查看jdk安裝路徑
方法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
方法2:使用rpm -qa | grep java
如果JDK是源碼安裝的話,那么這個方法也是行不通的。也就是說rpm –ql packagename
也是有一定局限性的。
[root@localhost ~]# 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 [root@localhost ~]# 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--
擴展知識:
查看java版本號--使用java -version
[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)
查看jdk的執行路徑--使用which java
which java定位到的是java程序的執行路徑。網上的資料都是人云亦云,完全不去思考。那么怎么定位到java的安裝路徑呢?下面我們來看看例子吧,如下所示:
[root@localhost ~]# which java /usr/bin/java [root@localhost ~]# ls -lrt /usr/bin/java lrwxrwxrwx. 1 root root 22 Aug 17 15:12 /usr/bin/java -> /etc/alternatives/java [root@localhost ~]# 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 [root@localhost ~]# [root@localhost ~]# cd /usr/lib/jvm [root@localhost 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 [root@localhost jvm]#
whereis java
也是如此,它本身不能定位到安裝路徑。可以通過上面例子去定位安裝路徑
到此,相信大家對“linux如何查看jdk安裝路徑”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。