如果您安装了多个 Java 版本,请使用:
$ /usr/libexec/java_home --verbose
或者:
$ /usr/libexec/java_home -V
(这是一个大写的 V!)
列出所有版本和架构。
样本输出:
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
12.0.1 (x86_64) "Oracle Corporation" - "Java SE 12.0.1" /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home
1.8.202.08 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_282 (x86_64) "Amazon" - "Amazon Corretto 8" /Users/username/Library/Java/JavaVirtualMachines/corretto-1.8.0_282/Contents/Home
1.8.0_202 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home