I installed Java11 using Homebrew running the command on my M1 mbp
brew search java
brew install java11
Which installed the java version. Then when I run
brew info java
I get this
openjdk: stable 17.0.1 (bottled) [keg-only]
Development kit for the Java programming language
https://openjdk.java.net/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openjdk.rb
License: GPL-2.0-only with Classpath-exception-2.0
==> Dependencies
Build: autoconf ✔
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
openjdk is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides similar software and installing this software in
parallel can cause all kinds of trouble.
==> Analytics
install: 229,799 (30 days), 652,569 (90 days), 2,040,179 (365 days)
install-on-request: 64,996 (30 days), 187,761 (90 days), 591,813 (365 days)
build-error: 5,513 (30 days)
I ran the sudo command under Caveats but I don't know if it did anything. When I run
Java --version
I get this
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
I don't understand why this is happening. I had Java up and running before but I had to format and install a fresh copy of the OS and now when I'm trying to install Java again Im running into this problem. Im assuming the symlink between Homebrew java install location isn't linking with the system java location, but I could be wrong.