Update 2019-11-16: I updated the syntax for the homebrew cask search as “brew cask search” is deprecated. Also, while the post below still mentions the java8 cask, only the java6 and java 11 casks are currently available.
Update 2019-05-07: The java8 cask is affected by recent licensing changes by Oracle. There’s a discussion over on github about this. I’m leaving the post up partially for historic context. The java8 cask is no longer available, at least at the time of writing.
In an earlier post, I described how to install the latest version of the Oracle Java JDK using homebrew. What hadn’t been completely obvious to me when I wrote the original blog post is that the ‘java’ cask will install the latest major version of the JDK. As a result, when I upgraded my JDK install today, I ended up with an upgrade from Java 8 to Java 9. On my personal machine that’s not a problem, but what if I wanted to stick with a specific major version of Java?