The official instructions from Firebase simply say
Java version 1.8 or higher. ... that links to https://openjdk.java.net/install/ It's not super clear to me how to install it from there.
First install Homebrew (https://brew.sh/)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then install Java (source)
brew install java
Then add Java to your PATH in .zprofile
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"