Common
Install a specific Java JDK version with homebrew on Mac OS
16. February 2018
0

Installing java the oracle way is somehow annoying and the Mac OS builtin java is also not that awesome. So I use homebrew for years to install java. The simplest approach is to just install it with ‘brew cask install java’ but this will install the latest available version. In my case this was java 9 which is not bad at all but I needed java 8. So I looked around the good old internet and stumbled upon the versions cask which seems to add a variety of versions to some casks. Do the following to install java 8 or even java 6 if you like.

brew tap caskroom/versions

brew cask install java8

 

If you want to use the installed version per default, you might want to modify JAVA_HOME:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home 

 

Execute java to check if it works:

java -version