当/usr/libexec/java_home返回错误时,如何在Macos Monterey中设置Java_home?

发布于 2025-02-03 18:54:02 字数 889 浏览 3 评论 0原文

我最近获得了这款新的MacBook Pro(2021)16“ Macos Monterey,并尝试安装Java(OpenJDK11)。我安装了Homebrew并使用Brew Install opentjdk@11安装Java。我在执行时会受到关注。 java - version命令,

openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment Homebrew (build 11.0.15+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.15+0, mixed mode)

但是当我执行/usr/usr/libexec/java_home时,我会得到以下内容,

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

在添加java_home之后,我也将其设置为java_home $(/usr/libexec/java_home) 〜/.zshrc

= 的问题

www.java.com,然后使用brew重新安装,但仍会遇到相同 “ rel =“ nofollow noreferrer”> “

I recently got this new MacBook Pro (2021) 16" with MacOs Monterey and trying to install Java (openjdk11). I installed Homebrew and used brew install openjdk@11 to install java. I get following when executed java --version command,

openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment Homebrew (build 11.0.15+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.15+0, mixed mode)

But when I execute /usr/libexec/java_home, I get the following,

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

Which I also had set as my JAVA_HOME after adding JAVA_HOME=$(/usr/libexec/java_home) to ~/.zshrc.

Even the folder /Library/Java/JavaVirtualMachines/ is empty.

Tried uninstalling according to www.java.com and then reinstall using brew but still getting the same issue.

Terminal

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

像极了他 2025-02-10 18:54:02

在自制OpenJDK公式页面上(上次检查:2022年12月19日),
是说的注释:

对于系统,Java包装器可以找到此JDK,并与
sudo ln -sfn $(brew -prefix)/opt/openjdk/libexec/openjdk.jdk.jdk/library/java/javavirtualmachines/openjdk.jdk.jdk.jdk.jdk

如果我需要的话,您需要您代码>在外壳中的变量,您可以在〜/.zshrc :(

export JAVA_HOME=$(/usr/libexec/java_home)

使用Macos Monterey和Ventura Update进行测试)中添加它。

On the Homebrew OpenJDK formula page (last check: 19 dec 2022),
there is this note that says:

For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn $(brew --prefix)/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

If like me you need the JAVA_HOME variable in your shell, you can add this in your ~/.zshrc:

export JAVA_HOME=$(/usr/libexec/java_home)

(Tested with MacOS Monterey and Ventura update).

坦然微笑 2025-02-10 18:54:02

无法解决原始问题,然后使用brew install -cask temurin11 https:// .NET/安装/)并没有任何问题。

Could not solve the Original Problem then used brew install --cask temurin11 (https://adoptium.net/installation/) and installed Java with no problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文