只需要一个简单的命令
/usr/libexec/java_home -V
比如我的输出如下
Matching Java Virtual Machines (3): 11.0.1, x86_64: "OpenJDK 11.0.1" /Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home 1.8.0_202, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home 1.8.0_201, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home /Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home
最后一行表示当前的 Java 所在目录,这个我们可以通过 java -version
来核实
openjdk version "11.0.1" 2018-10-16 OpenJDK Runtime Environment 18.9 (build 11.0.1+13) OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
或者通过 ls -lh /usr/bin/java
来查看
/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
目前尚无回复