In case you need this, if you install Java via homebrew, e.g. brew install openjdk, you’ll need to add this to your ~/.zshrc

export JAVA_HOME="/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home"

and then run the typical sudo R CMD javareconf to get hooked back up.