'JAVA_HOME does not show all installed JDKs on macOS v12.1

Trying to install Java11. Looked at existing JDKs using /usr/libexec/java_home -V and it returned only one Matching Java Virtual Machine 1.8.0_292 (x86_64). Checked with Homebrew using brew search Java and discovered Java11 is already installed at /usr/local/Cellar/openjdk@11. Why won't JAVA_HOME recognise this? How to make Java11 the default Java instead of the 1.8.0_292?



Sources

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

Source: Stack Overflow

Solution Source