Create a gist now

Instantly share code, notes, and snippets.

Embed
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)
@JeOam

This comment has been minimized.

Show comment
Hide comment
@JeOam

JeOam Mar 3, 2016

Install Java 7 on Mac OX

brew cask install caskroom/versions/java7
Owner

JeOam commented Mar 3, 2016

Install Java 7 on Mac OX

brew cask install caskroom/versions/java7
@khanactl

This comment has been minimized.

Show comment
Hide comment
@khanactl

khanactl Nov 12, 2016

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

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

@eddiejaoude

This comment has been minimized.

Show comment
Hide comment
@eddiejaoude

eddiejaoude Jan 12, 2017

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

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

@piqueen314

This comment has been minimized.

Show comment
Hide comment
@piqueen314

piqueen314 Jan 20, 2017

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

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

@alvint

This comment has been minimized.

Show comment
Hide comment
@alvint

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

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

This comment has been minimized.

Show comment
Hide comment
@bogste

bogste Oct 17, 2017

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.

bogste commented Oct 17, 2017

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.

@randy3k

This comment has been minimized.

Show comment
Hide comment
@randy3k

randy3k Oct 23, 2017

Thanks @bogste

brew cask install caskroom/versions/java8

works for me.

randy3k commented Oct 23, 2017

Thanks @bogste

brew cask install caskroom/versions/java8

works for me.

@madwyn

This comment has been minimized.

Show comment
Hide comment
@madwyn

madwyn Feb 25, 2018

brew cask install java

madwyn commented Feb 25, 2018

brew cask install java

@hareentej2

This comment has been minimized.

Show comment
Hide comment
@hareentej2

hareentej2 Mar 12, 2018

@madwyn brew cask install java isn't working with error

==> Downloading http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926
######################################################################## 100.0%
curl: (6) Could not resolve host: download.oracle.com

curl: (22) The requested URL returned error: 408 Request Time-out
Error: Download failed on Cask 'java' with message: Download failed: http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_osx-x64_bin.dmg
The incomplete download is cached at /Users/hareentej22/Library/Caches/Homebrew/Cask/java--9.0.4,11:c2514751926b4512b076cc82f959763f.dmg.incomplete

hareentej2 commented Mar 12, 2018

@madwyn brew cask install java isn't working with error

==> Downloading http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926
######################################################################## 100.0%
curl: (6) Could not resolve host: download.oracle.com

curl: (22) The requested URL returned error: 408 Request Time-out
Error: Download failed on Cask 'java' with message: Download failed: http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_osx-x64_bin.dmg
The incomplete download is cached at /Users/hareentej22/Library/Caches/Homebrew/Cask/java--9.0.4,11:c2514751926b4512b076cc82f959763f.dmg.incomplete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment