Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing JRE using homebrew

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?
like image 583
pensee Avatar asked Aug 07 '26 07:08

pensee


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
like image 155
Ortomala Lokni Avatar answered Aug 09 '26 21:08

Ortomala Lokni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!