Starting from macOS Big Sur (ver. 11.2.3), macOS doesn’t include pre-installed Java any more, the best option is to install AdoptOpenJDK.
You can download the OpenJDK pkg binary and install it manually like here,
or install AdoptOpenJDK via
brew in your favourite terminal:
Hope it helps.
LastMod 2022-06-06 (f027512d)