gpt4 book ai didi

java - 有没有办法找到 OS X 上安装的 Java 版本的完整列表?

转载 作者:行者123 更新时间:2023-12-01 14:20:35 25 4
gpt4 key购买 nike

我试图找到我的 Mac OS X 上安装的 JDK 版本的完整列表。
我确实尝试过 javac -version但它只显示在 bashrc 中设置的当前版本。
任何帮助,将不胜感激。

最佳答案

Mac OS X 有一个很酷的二进制文件 (/usr/libexec/java_home),它从当前用户的设置返回到 Java 主目录的路径。您可能想要发布:

/usr/libexec/java_home -V
它使用如下架构打印完整的 JVM 列表:
Matching Java Virtual Machines (2):
13, x86_64: "OpenJDK 13" /Library/Java/JavaVirtualMachines/openjdk-13.jdk/Contents/Home
1.8.0_265, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/openjdk-13.jdk/Contents/Home
如果要打印特定 JDK 版本的 JAVA_HOME 路径,可以这样做:
/usr/libexec/java_home -v 1.8
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
您可以看到以下完整的使用选项:
Usage: java_home [options...]
Returns the path to a Java home directory from the current user's settings.

Options:
[-v/--version <version>] Filter Java versions in the "JVMVersion" form 1.X(+ or *).
[-a/--arch <architecture>] Filter JVMs matching architecture (i386, x86_64, etc).
[-d/--datamodel <datamodel>] Filter JVMs capable of -d32 or -d64
[-t/--task <task>] Use the JVM list for a specific task (Applets, WebStart, BundledApp, JNI, or CommandLine)
[-F/--failfast] Fail when filters return no JVMs, do not continue with default.
[ --exec <command> ...] Execute the $JAVA_HOME/bin/<command> with the remaining arguments.
[-R/--request] Request installation of a Java Runtime if not installed.
[-X/--xml] Print full JVM list and additional data as XML plist.
[-V/--verbose] Print full JVM list with architectures.
[-h/--help] This usage information.

关于java - 有没有办法找到 OS X 上安装的 Java 版本的完整列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63654909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com