Java Runtimes
On MacOS, despite your best efforts you'll probably need a JRE (Java Runtime Environment) at some point. If doing development, it can be easier to install the whole JDK instead (Java Development Kit).
Which do I pick?
For more complete information, check out Java Is Still Free.
OpenJDK
Note
AdoptOpenJDK and OpenJDK are the same thing. AdoptOpenJDK are just prebuilt binaries.
shell
# Install the JDK itself
brew install openjdk
# Install version 11, usually more compatible.
brew install openjdk@11
# Follow the instructions under 'Caveats'. Usually it'll be
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
Temurin
Temurin is another open-source JDK built on OpenJDK by Adoptium (owned by the Eclipse Foundation).
It can be installed from its Homebrew cask or downloaded from its releases page.
shell
# Install Temurin.
brew install --cask temurin