I am looking to install Java on Mac using Homebrew. This works fine using the command
brew cask install java.This installs the latest stable version which is currently - 1.8.0_141
However how can I install a specific version for example 1.8.0_131.
Asked
Active
Viewed 7.4k times
48
icodes
- 1,322
- 3
- 21
- 45
-
http://effectif.com/mac-os-x/installing-specific-version-of-homebrew-formula this could help you – Nicholas Tsaoucis Jun 19 '17 at 13:49
-
Not an exact duplicate, but the answer is there: https://stackoverflow.com/questions/26252591/mac-os-x-and-multiple-java-versions – Stijn Van Bael Sep 26 '17 at 09:33
2 Answers
80
- Install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Update homebrew if already installed:
brew update
- allow brew to lookup versions
brew tap homebrew/cask-versions
- list available java versions
brew search java
Optional: to find out the minor version of java
brew info --cask java8
- install java 8 (or any other version available)
brew install --cask java8
Tinu1976CH
- 23
- 8
Jubba Smail
- 1,155
- 10
- 15
-
16it's not the answer for the question, it just install the latest java 8 version – Marx Oct 19 '17 at 09:37
-
7when you run step 4, you will get a list of available Java versions, step 5 just to demonstrate installing Java version 8 – Jubba Smail Oct 19 '17 at 12:37
-
2This seems to be outdated. Do you know how to install java8 with brew now? It intalled java9 and the other command for versions does not show other versions of java – wuno Nov 10 '17 at 03:25
-
5I just tried again, it's working fine, please follow the steps, you need to run "brew tap caskroom/versions" first. – Jubba Smail Nov 10 '17 at 11:35
-
12As instructed by homebrew, the command that worked for me was `brew cask install caskroom/versions/java8` First I ran `brew cask uninstall java` to remove the other version I had previously installed. – Mike Vallano Nov 19 '17 at 14:44
-
Do not forget to update JAVA_HOME: in your ~/.bashrc or ~/.zshrc file: `export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)` – sbaechler Oct 19 '18 at 15:03
-
I'm receiving `Error: Calling \`brew cask search\` is disabled! Use \`brew search\` instead.` when running `brew cask search java` – zudduz Oct 31 '18 at 18:15
-
-
Use above instructions plus jEnv (http://www.jenv.be/) to manage multiple versions of JDK/JRE on the same machine and you'll have the ability to switch between java dev environments without a hassle! – RickB Nov 24 '18 at 15:33
-
1`brew cask install caskroom/versions/java8` and `brew cask install homebrew/cask-versions/java8` don't work anymore, see [here](https://github.com/Homebrew/homebrew-cask-versions/issues/7253) for more details. – Sean Breckenridge Apr 17 '19 at 21:11
-
5The workaround for now is to `brew tap homebrew/cask-versions` and use `brew cask install homebrew/cask-versions/adoptopenjdk8` – Sean Breckenridge Apr 19 '19 at 21:32
19
Raising Sean Breckenridge's comment as an answer to increase visibility:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap homebrew/cask-versions
brew cask install homebrew/cask-versions/adoptopenjdk8
There is no longer cask named "java8".
user1338062
- 10,623
- 3
- 64
- 60
-
1╰─$ brew cask install homebrew/cask-versions/adoptopenjdk8 Error: Unknown command: cask – Ashish Jun 15 '21 at 09:54
-
3