下文笔者讲述Linux中查看JDK的安装路径的方法分享,如下所示
实现思路:方式1:echo $JAVA_HOME 输出的值为java路径方式2:使用which 方法查找出java的安装包,which查找原理,依次找出java命令运行对应的软链接,依次找出最终的安装位置
例:
[root@node0 ~]# java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
[root@node0 ~]# echo $JAVA_HOME[root@node0 ~]# which java
/usr/bin/java
[root@node0 ~]# ls -lrt /usr/bin/java
lrwxrwxrwx. 1 root root 22 3月 12 16:16 /usr/bin/java -> /etc/alternatives/java
[root@node0 ~]# ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 37 3月 12 16:16 /etc/alternatives/java -> /usr/java/jdk1.8.0_271-amd64/bin/java
[root@node0 ~]# ls -lrt /usr/java/jdk1.8.0_271-amd64/bin/java
-rwxr-xr-x. 1 root root 8712 9月 17 2020 /usr/java/jdk1.8.0_271-amd64/bin/java
[root@node0 ~]# cd /usr/java/jdk1.8.0_271-amd64/bin/
[root@node0 bin]# dir
appletviewer idlj java javafxpackager javapackager jcmd jdb jinfo jps jstack jvisualvm orbd rmic schemagen tnameserv wsimport
ControlPanel jar javac javah java-rmi.cgi jconsole jdeps jjs jrunscript jstat keytool pack200 rmid serialver unpack200 xjc
extcheck jarsigner javadoc javap javaws jcontrol jhat jmap jsadebugd jstatd native2ascii policytool rmiregistry servertool wsgen