Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Install Java 8 on OS X

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)
Owner

JeOam commented Mar 3, 2016

Install Java 7 on Mac OX

brew cask install caskroom/versions/java7

how does one get around admin level authorization when installing as a non-admin user which homebrew recommends? what am i missing here?

@khanactl pre-pending a command with sudo to get admin permissions, however this is not recommended and should not be required by brew

@khanactl
sudo chown -R $(whoami) /usr/local
to change ownership and permissions to your account

alvint commented Apr 6, 2017

@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.

bogste commented Oct 17, 2017 edited

Thanks for this!

Since that command will always install the latest version of Java (currently 9), for the older Java 8, the command is: brew cask install caskroom/versions/java8.
Also, one can query what will be installed via brew cask info caskroom/versions/java8 beforehand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment