Skip to content

Instantly share code, notes, and snippets.

@JeOam
Last active May 5, 2020 03:15
  • Star 62 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save JeOam/a926dbb5145c4d0789c1 to your computer and use it in GitHub Desktop.

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)
@JeOam
Copy link
Author

JeOam commented Mar 3, 2016

Install Java 7 on Mac OX

brew cask install caskroom/versions/java7

@khanactl
Copy link

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

@eddiejaoude
Copy link

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

@piqueen314
Copy link

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

@alvint
Copy link

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
Copy link

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
Copy link

randy3k commented Oct 23, 2017

Thanks @bogste

brew cask install caskroom/versions/java8

works for me.

@madwyn
Copy link

madwyn commented Feb 25, 2018

brew cask install java

@hareentej2
Copy link

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

@margaretdax
Copy link

Thanks @bogste! @JeOam might be worth updating since you've got high results on google w/ this Gist?

@musha34
Copy link

musha34 commented Apr 11, 2019

Need Java8 but accidentally installed latest java12. What's the procedure to uninstall 12?

--- Nevermind. I did it with:
brew cask uninstall java

@kazimdsaidul
Copy link

Cask 'java8' is unavailable: '/usr/local/Homebrew/Library/Taps/caskroom/homebrew-versions/Casks/java8.rb' does not exist.

@programmerjee
Copy link

programmerjee commented May 4, 2020

Update: caskroom/versions was moved. Tap homebrew/cask-versions instead.
brew cask install homebrew/cask-versions/java8

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