Skip to content

Instantly share code, notes, and snippets.

@JeOam
Last active May 5, 2020 03:15
Show Gist options
  • Star 62 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save JeOam/a926dbb5145c4d0789c1 to your computer and use it in GitHub Desktop.
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)
@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