Installing JRE using homebrew

Viewed 422

I used the command brew install openjdk@11 to install Java on my mac. But when I run
java --version, I get the following message:

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

  1. How do I install JRE using HomeBrew?
  2. Which JRE version do I need to install?
1 Answers

The answer to your question can be found by running:

brew info openjdk@11

Part of the output is:

For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

openjdk@11 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have openjdk@11 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc
Related