Update: https://www.cyanhall.com/posts/notes/7.homebrew-cheatsheet/#java
on El Capitan, after installing the brew...
$ brew update
$ brew tap caskroom/cask
$ brew install Caskroom/cask/java
And Java 8 will be installed at /Library/Java/JavaVirtualMachines/jdk1.8.xxx.jdk/
Check version:
$ java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
@piqueen314 I think @khanactl is referring to the fact that the installation folder (/Library/Java/JavaVirtualMachines/) is owned by root and is therefore not writeable by the HomeBrew user. As I'm sure he's already figured out, HomeBrew will prompt you for your password to run
sudo
if necessary.