Installing Java JDK on OS X using Homebrew
Homebrew is a package manager that makes it really easy for us to install all sorts of development tools such as MySQL, Mongo, Ruby on Rails and in this case, Java. Below are the steps required to install Java usng Homebrew.
Step 0 - Install Homebrew
Homebrew does not come pre-installed with Mac so you'll have to install it yourself. Thankfully, it's a single line of code that you paste into terminal. Here are instructions on how to install Homebrew on Mac.
Step 1 - Install Cask
brew cask installs macOS apps, fonts and plugins and other non-open source software. Java is not open source so we'll need to install this first.
brew tap caskroom/cask
Step 2 - Install Java
This single command will install the latest version of Java through
brew cask install caskroom/versions/java8
Step 3 - Verify Your Work
brew cask info java