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.