I tried to install Java 9 and 10 on macOS with Homebrew:
brew cask install java9
I got the following error:
Error: Cask 'java9' is unavailable: No Cask with this name exists.
and:
brew cask install caskroom/versions/java9
gave me:
Error: Cask 'java9' is unavailable:
'/usr/local/Homebrew/Library/Taps/caskroom/homebrew-versions/Casks/java9.rb' does not exist.
Why doesn't this work and how can I install Java on macOS?