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的安装路径呢?下面我们来看看例子吧,如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[[email protected] /]# which java
/usr/bin/java
[[email protected] /]# ls -lrt /usr/bin/java
lrwxrwxrwx 1 root root 22 1月 4 11:24 /usr/bin/java -> /etc/alternatives/java
[[email protected] /]# ls -lrt /etc/alternatives/java
lrwxrwxrwx 1 root root 46 1月 4 11:24 /etc/alternatives/java -> /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
[[email protected] /]#
[[email protected] /]#
[[email protected] /]#
[[email protected] /]# cd /usr/lib/jvm
[[email protected] jvm]# ls
java java-1.7.0 java-1.7.0-openjdk-1.7.0.121.x86_64 java-1.7.0-openjdk.x86_64 java-openjdk jre jre-1.7.0 jre-1.7.0-openjdk.x86_64 jre-openjdk
[[email protected] jvm]#
|
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/1452.html