1:echo $JAVA_HOMEjava
使用$JAVA_HOME的話能定位JDK的安裝路徑的前提是配置了環境變量$JAVA_HOME,不然以下所示,根本定位不到JDK的安裝路徑jvm
[root@localhost ~]# java -versionui
java version "1.7.0_65"spa
OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-x86_64 u65-b17)3d
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)code
[root@localhost ~]# echo $JAVA_HOMEblog
2:which javaip
首先要申明一下which java是定位不到安裝路徑的。which java定位到的是java程序的執行路徑。網上的資料都是人云亦云,徹底不去思考。那麼怎麼定位到java的安裝路徑呢?下面咱們來看看例子吧,以下所示:資源
[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 ~]# 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 也是如此,它自己不能定位到安裝路徑。能夠經過上面例子去定位安裝路徑get
資源地址:http://www.cnblogs.com/kerrycode/