On Mac, Homebrew is the de-facto package manager, and Homebrew Cask is the app manager. I’m going to use Cask to install Java 7 and 8.
Install Homebrew Cask first if you haven’t:
brew update
brew tap caskroom/cask
Keywords: Java, JDK (Java Development Kit), MacOS, Homebrew, Specific Version
This how-to guide covers how to install different versions of the JDK on MacOS with Homebrew.