Maintaining Java Installs on macOS Using Homebrew Cask
Recently, I upgraded my MacBook Pro from a old, trusty Yosemite to Sierra, and reluctantly had to clean out the old JDK versions I had accumulated over a few years. I also wanted to have a Java 9 JDK to play around with the new module system and API’s.
Good news is that, for a while now, you have been able to install and upgrade multiple versions of JDK using only your shell, without having to deal with Oracle’s graphical installers.
To install Java from scratch, install Homebrew Cask
cask-update (you need to have Homebrew already installed) first, then install Java using Cask:
brew tap buo/cask-upgrade & brew tap caskroom/versions brew cask install java8