'How to see brew installed java with java -version command?

I have installed java open jdk latest version with homebrew with the following command:

brew install openjdk

I try to to check installed versions with the command

/usr/libexec/java_home -V

Nothing showing.

And the command java -version also showing :

No Java runtime present, requesting install

Where is my java ? How can I see installed version and use it and see it with java -version command



Solution 1:[1]

I recommend installing the JDK cask temurin instead:

brew uninstall openjdk
brew install temurin

Otherwise, you must symlink the the openjdk formula into /Library/Java/JavaVirtualMachines:

sudo ln -sfn $(brew --prefix openjdk)/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1