linux system finds the currently used JDK path

Original link: https://www.cnblogs.com/cnmenglang/p/6270375.html

1.echo $JAVA_HOME

If you use $JAVA_HOME to locate the JDK installation path, the premise is that the environment variable $JAVA_HOME is configured. Otherwise, as shown below, the JDK installation path cannot be located at all

[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. which java

First of all, we must declare which java cannot locate the installation path. Which java locates is the execution path of the java program. The information on the Internet is all about others, and I don't think about it at all. So how to locate the java installation path? Let's take a look at an example, as shown below:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

[root@iZ2ze9uuc43mja8vg9ytemZ /]# which java

/usr/bin/java

[root@iZ2ze9uuc43mja8vg9ytemZ /]# ls -lrt /usr/bin/java

lrwxrwxrwx 1 root root 22 1月   4 11:24 /usr/bin/java -> /etc/alternatives/java

[root@iZ2ze9uuc43mja8vg9ytemZ /]# 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

[root@iZ2ze9uuc43mja8vg9ytemZ /]#

[root@iZ2ze9uuc43mja8vg9ytemZ /]#

[root@iZ2ze9uuc43mja8vg9ytemZ /]#

[root@iZ2ze9uuc43mja8vg9ytemZ /]# cd /usr/lib/jvm

[root@iZ2ze9uuc43mja8vg9ytemZ 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

[root@iZ2ze9uuc43mja8vg9ytemZ jvm]#

 

Guess you like

Origin blog.csdn.net/u010472858/article/details/95167626