学到个命令:
Github-Id-VampireAchao:~ achao$ /usr/libexec/java_home -V Matching Java Virtual Machines (5): 21.0.1 (arm64) "Oracle Corporation" - "OpenJDK 21.0.1" /Users/achao/Library/Java/JavaVirtualMachines/openjdk-21.0.1/Contents/Home 20.0.2 (arm64) "Oracle Corporation" - "OpenJDK 20.0.2" /Users/achao/Library/Java/JavaVirtualMachines/openjdk-20.0.2/Contents/Home 17.0.8.1 (arm64) "Azul Systems, Inc." - "Zulu 17.44.53" /Users/achao/Library/Java/JavaVirtualMachines/azul-17.0.8.1/Contents/Home 11.0.20.1 (arm64) "Azul Systems, Inc." - "Zulu 11.66.19" /Users/achao/Library/Java/JavaVirtualMachines/azul-11.0.20.1/Contents/Home 1.8.0_372 (arm64) "Azul Systems, Inc." - "Zulu 8.70.0.23" /Users/achao/Library/Java/JavaVirtualMachines/azul-1.8.0_372/Contents/Home /Users/achao/Library/Java/JavaVirtualMachines/openjdk-21.0.1/Contents/Home
还可以指定版本号:
Github-Id-VampireAchao:~ achao$ /usr/libexec/java_home -v 1.8 /Users/achao/Library/Java/JavaVirtualMachines/azul-1.8.0_372/Contents/Home Github-Id-VampireAchao:~ achao$ /usr/libexec/java_home -v 20 /Users/achao/Library/Java/JavaVirtualMachines/openjdk-20.0.2/Contents/Home