How to install Java 8 on Mac

1,139,618

Solution 1

Oracle has a poor record for making it easy to install and configure Java, but using Homebrew, the latest OpenJDK (Java 14) can be installed with:

brew install --cask adoptopenjdk8

For the many use cases depending on an older version (commonly Java 8), the AdoptOpenJDK project makes it possible with an extra step.

brew tap adoptopenjdk/openjdk
brew install --cask adoptopenjdk8

Existing users of Homebrew may encounter Error: Cask adoptopenjdk8 exists in multiple taps due to prior workarounds with different instructions. This can be solved by fully specifying the location with brew install --cask adoptopenjdk/openjdk/adoptopenjdk8.

Solution 2

Note: Oracle Java 8/9/10 is no longer available for public download (license change).

First install and update brew from Terminal:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

brew tap homebrew/cask-versions

brew update

NEW as of June 2019

To install the JDKs from AdoptOpenJDK:

brew tap adoptopenjdk/openjdk

brew install --cask adoptopenjdk8
brew install --cask adoptopenjdk9
brew install --cask adoptopenjdk10
brew install --cask adoptopenjdk11

OLD

Java 8:

brew install --cask java8

Java Latest:

brew install --cask java

Solution 3

Java8 is no longer available on homebrew, brew install java8 will not work.

Instead, use:

brew cask install adoptopenjdk/openjdk/adoptopenjdk8

See this commit for technical details.

Please note as well you may see issues around Cask adoptopenjdk8 exists in multiple taps. This is a known issue, currently being worked on, which you can see here:

https://github.com/AdoptOpenJDK/homebrew-openjdk/issues/106

For those who don't want to run through the details, here is a summary:

# To install JDK8
brew cask install adoptopenjdk/openjdk/adoptopenjdk8

# To be able to safely run 'brew cleanup'
brew untap adoptopenjdk/openjdk
brew untap caskroom/versions
brew cleanup

Solution 4

I just did this on my MBP, and had to use

$ brew tap homebrew/cask-versions
$ brew cask install java8

in order to get java8 to install.

Solution 5

Assumption: Mac machine and you already have installed homebrew.

Install cask (with Homebrew 0.9.5 or higher, cask is included so skip this step):

$ brew tap caskroom/cask
$ brew tap caskroom/versions

To install latest java:

$ brew cask install java

To install java 8:

$ brew cask install adoptopenjdk/openjdk/adoptopenjdk8

If you want to install/manage multiple version then you can use 'jenv':

Install and configure jenv:

$ brew install jenv
$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(jenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile

Add the installed java to jenv:

$ jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
$ jenv add /Library/Java/JavaVirtualMachines/jdk1.11.0_2.jdk/Contents/Home

To see all the installed java:

$ jenv versions

Above command will give the list of installed java:

* system (set by /Users/lyncean/.jenv/version)
1.8
1.8.0.202-ea
oracle64-1.8.0.202-ea

Configure the java version which you want to use:

$ jenv global oracle64-1.6.0.39

To set JAVA_HOME:

$ jenv enable-plugin export
Share:
1,139,618
user3763100
Author by

user3763100

Updated on July 08, 2022

Comments

  • user3763100
    user3763100 almost 2 years

    Editors note: This question was asked in 2014, and the answers may be outdated.


    I want to do some programming with the latest JavaFX, which requires Java 8. I'm using IntelliJ 13 CE and Mac OS X 9 Mavericks. I ran Oracle's Java 8 installer, and the files look like they ended up at

    /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk
    

    but previous versions are at

    /System/Library/Java/JavaFrameworks/jdk1.6....
    

    Not sure why the latest installer puts this in /Library instead of /System/Library (nor what the difference is). But /usr/libexec/java_home doesn't find 1.8, so all the posts I've found on how to set your current java version don't work. I've tried adding a symbolic link to make it look like 1.8 is in the /System/Library... path, but it doesn't help. /usr/libexec/java_home -V still only lists the old Java 1.6.

    Ironically, the "Java" control panel under System Preferences shows only Java 1.8!

    Why doesn't Oracle's installer put it where it really goes? And how can I work around this problem?

  • barclay
    barclay over 8 years
    +1: i use this script and i agree, it's pretty useful for devs who have multiple projects that require different versions of Java.
  • ccpizza
    ccpizza over 8 years
    There is really no need to set any scripts as long as you only need to use a specific version system-wide. Basically all you need to do is add to your ~/.bashrc or ~/.bash_profile: export JAVA_HOME="/usr/libexec/java_home -v 1.8" and also add your $JAVA_HOME/bin to $PATH if the java installer didn't do it already. (NOTE: replace double quotes with backticks for /usr/libexec/java_home, can't enter literal backticks in comments..)
  • James
    James over 8 years
    I had to run this multiple times before the the dmg would download from oracle, each time it continued at the last point it left off.
  • Tommy
    Tommy over 8 years
    Interesting to note that this did not work for me on Mavericks, so it did not answer the OP's question, but it did work for me on Captain, so it was useful as an answer..
  • Benjineer
    Benjineer over 8 years
    @James - was probably a network issue. +1 for mentioning jenv
  • philwhln
    philwhln over 8 years
    For me, in El Kapitan, it would only download a few extra percent each time I ran it, so I ran it in a loop (in fish shell) and it eventually worked. while math "$status == 1"; brew install Caskroom/cask/java; end
  • eddywashere
    eddywashere over 8 years
    This works, but I did have to brew install Caskroom/cask/java many times because the transfer kept closing: curl: (18) transfer closed with 34724700 bytes remaining to read
  • davetw12
    davetw12 over 8 years
    As of December 2015, it is now unnecessary to install cask manually as it is now part of homebrew's installation. So after updating homebrew via brew update, you are set to use brew cask.
  • James Lawson
    James Lawson over 8 years
    Didn't work for me on Yosemite (OSX v10.10.5). I get Error: Cask 'java' definition is invalid: Bad header line: parse failed ... Seems like this works only for El Capitan and not for any version preceding version of OSX (Yosemite, Mavericks..., )
  • lewiguez
    lewiguez over 8 years
    I'm also getting the parse failed error, and I'm on El Capitan. Has anyone else encountered this and/or found a solution?
  • icfantv
    icfantv over 8 years
    if you want to install java 7 (along side java 8) via homebrew, the command is brew tap caskroom/versions followed by brew cask install java7.
  • enderland
    enderland about 8 years
    Thanks, it's amazing how horrible the Java installation process using the "official" links/docs are.
  • Pradeep
    Pradeep about 8 years
    Oracle official site is giving weired errors, this is life savior
  • Christian Long
    Christian Long about 8 years
    jenv is a very convenient tool for managing multiple versions of Java, either globally or locally per-directory.
  • Adil Hussain
    Adil Hussain about 8 years
    I installed homebrew fresh on a new OS X El Capitan machine and didn't have to run the brew tap command in the answer above. The first and third commands were sufficient.
  • Andrew
    Andrew about 8 years
    Good example using Docker, not sure why you got a downvote before.
  • BitwiseMan
    BitwiseMan almost 8 years
    @l3x - I suggested an edit that would update your answer to what davetw12 said. It was rejected because reviewers felt it was too different from your answer. Would you be willing to make your answer a shared answer so we can make this right and current? Or otherwise accept the edit?
  • Calrion
    Calrion over 7 years
    @tandrewnichols I just ran brew cask install java on my El Capitan Mac and it's downloading jdk-8u112-macosx-x64.dmg.
  • whitfin
    whitfin over 7 years
    I'd imagine the downvote because this does not answer the question of running Java on OS X/MacOS. Answering "How do I do this on platform X" with "Just use a VM/shim to do it on platform Y" is not productive.
  • AKFourSeven
    AKFourSeven over 7 years
    If having anymore issue with JRE or JDK try gist.github.com/johan/10590467
  • cambunctious
    cambunctious about 7 years
    it DOES install JDK. brew cask info java
  • Rich Apodaca
    Rich Apodaca about 7 years
    In contrast to @tandrewnichols I found this procedure installed JDK as well as the runtime - so full Java support.
  • Rolando
    Rolando almost 7 years
    If you installed java using the Oracle updater and want Homebrew to manage it, do I have to fully uninstall the Oracle Java first?
  • bananaforscale
    bananaforscale almost 7 years
    brew cask install java installed jdk ftw
  • shiri
    shiri over 6 years
    Note that as of October 2017, the default brew command (as well as most of those in the comments) will install whatever is the latest major version JDK (i.e. java 9) rather than a specific older one (for example, Java 8 as in the OP). See this helpful blog post for a description of how to use brew to install an earlier version of Java if needed. lonecpluspluscoder.com/2017/10/08/…
  • Karl Pokus
    Karl Pokus over 6 years
    How does that help?
  • interrupt
    interrupt over 6 years
    It helped me with installing specific version of java. Now when java 9 is out, running "brew cask install java" installs java 9. "brew cask install java8" wasn't working for me until I ran "brew tap caskroom/versions".
  • Sindhu
    Sindhu over 6 years
    What is cask significance here ?
  • hendrix
    hendrix over 6 years
    Yes, brew tap caskroom/versions is required before installing java8
  • danvk
    danvk about 6 years
    In case others missed this, the brew cask install java8 approach installs java in /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/‌​Home/bin/java.
  • Arun
    Arun about 6 years
    brew cask install caskroom/versions/java8
  • tresf
    tresf about 6 years
    Works on 10.8 after apple git is replaced with homebrew git. :) Very nice.
  • Jim Ford
    Jim Ford about 6 years
    3/28/18 - try: brew install caskroom/version/java8
  • atlas_scoffed
    atlas_scoffed almost 6 years
    Anyone wanting Java 7: java7 is not available in cask versions, but zulu7 appears to work instead. github.com/Homebrew/homebrew-cask/issues/9447
  • Naruto Sempai
    Naruto Sempai almost 6 years
    or just brew install homebrew/cask-versions/java8 for the win!
  • Min2
    Min2 almost 6 years
    Error: Cask 'java8' is unavailable: No Cask with this name exists.
  • Elderry
    Elderry over 5 years
    Error: Cask 'java8' is unavailable: No Cask with this name exists.
  • Felipe Augusto
    Felipe Augusto over 5 years
    Use brew tap caskroom/versions before to avoid this errors. @Min2
  • Shikhar Mishra
    Shikhar Mishra over 5 years
    On Mac OSX Sierra brew cask install caskroom/versions/java8
  • mark
    mark over 5 years
    I had to use the following commands brew tap homebrew/cask-versions; brew cask install java8
  • chovy
    chovy over 5 years
    curl: (22) The requested URL returned error: 404 Not Found Error: Download failed on Cask 'java8' with message: Download failed: https://download.oracle.com/otn-pub/java/jdk/8u192-b12/750e1‌​c8617c5452694857ad95‌​c3ee230/jdk-8u192-ma‌​cosx-x64.dmg
  • James Wierzba
    James Wierzba about 5 years
    What happens if I install java via brew, and java was already installed from some other method? Will brew handle this ok? Or do I need to explicitly uninstall first?
  • WeiChing 林煒清
    WeiChing 林煒清 about 5 years
    brew cask install java8 Error: Cask java8 exists in multiple taps:
  • kitaev
    kitaev about 5 years
    @danvk I install brew under ~/homebrew and hope the java can be installed under the ~/homebrew/bin, just like other apps, do you think it's possible and how to do that?
  • Nikhil Sahu
    Nikhil Sahu about 5 years
    jenv is quite easy and super useful. I have multiple projects that need java 8 and 11
  • Mizux
    Mizux about 5 years
    especially for native java development (e.g. using SWIG, JNI and LIBRARY_PATH)
  • Sean Breckenridge
    Sean Breckenridge about 5 years
    This doesn't work anymore, see here for more details.
  • Sean Breckenridge
    Sean Breckenridge about 5 years
    @WeiChingLin you can fix that by specifying which tap you want to install from. e.g. brew cask install caskroom/versions/java8 or brew cask install homebrew/cask-versions/java8. However, that wont work currently since oracle is phasing out their java8 download. See here for more details.
  • Siddhartha
    Siddhartha about 5 years
    Getting this: Error: Download failed on Cask 'java8' with message: Download failed: https://download.oracle.com/otn-pub/java/jdk/8u202-b08/19610‌​70e4c9b4e26a04e7f5a0‌​83f551e/jdk-8u202-ma‌​cosx-x64.dmg
  • Sean Breckenridge
    Sean Breckenridge about 5 years
    The workaround for now is to brew tap homebrew/cask-versions and use brew cask install homebrew/cask-versions/adoptopenjdk8
  • Marcelo Xavier
    Marcelo Xavier about 5 years
    It is not possible to install Java8 using Brew anymore because of Oracle license changes. Java8 is not public anymore for download.
  • Marcelo Xavier
    Marcelo Xavier about 5 years
    It is not possible to install Java8 using Brew anymore because of Oracle license changes. Java8 is not available for public download anymore.
  • cglacet
    cglacet about 5 years
    Why not making an alias for different version, like alias java8=/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Con‌​tents/Home/bin/java?
  • Jain Waldrip
    Jain Waldrip about 5 years
    Oh no! That must be very recent, because this workflow was working for me when I did it on my personal laptop just a couple weeks ago.
  • Sean Breckenridge
    Sean Breckenridge about 5 years
    Is there any difference in using AdoptOpenJDK/openjdk instead of using homebrew/cask-versions/adoptopenjdk8
  • Polpetta
    Polpetta about 5 years
    See stackoverflow.com/a/55775566/9306378 if you still want to use java8. Note that this uses OpenJDK though.
  • Koray Tugay
    Koray Tugay almost 5 years
    I get the following when I try your answer: Cask adoptopenjdk8 exists in multiple taps: caskroom/versions/adoptopenjdk8 adoptopenjdk/openjdk/adoptopenjdk8
  • Dave Kerr
    Dave Kerr almost 5 years
    @KorayTugay I have updated the answer, this should solve your issues!
  • Dave Kerr
    Dave Kerr almost 5 years
    @SeanBreckenridge - the HomeBrew team are working on it, at the moment it looks like AdoptOpenJDK will be used, but there is still some uncertainty, see the currently open issue github.com/AdoptOpenJDK/homebrew-openjdk/issues/106 for details!
  • Jain Waldrip
    Jain Waldrip almost 5 years
    Looks like since Oracle's Java went license-only, my homebrew has started installing Open JDK for me by default.
  • Sean Breckenridge
    Sean Breckenridge almost 5 years
    See this answer below for further details.
  • Adam Matan
    Adam Matan almost 5 years
    Java8 is not available for brew / cask anymore: github.com/Homebrew/homebrew-cask-versions/issues/7253
  • user924
    user924 almost 5 years
    Cask 'java8' is unavailable: No Cask with this name exists.
  • user924
    user924 almost 5 years
    Error: Cask 'java8' is unavailable: No Cask with this name exists.
  • user924
    user924 almost 5 years
    Error: Cask 'java8' is unavailable: No Cask with this name exists.
  • matbrgz
    matbrgz almost 5 years
    Why not rely on the Oracle installer? Has worked for me so far.
  • Yordan Georgiev
    Yordan Georgiev almost 5 years
    find /usr/local/Homebrew/Library/Taps/ | grep -i jdk | xargs rm -v if you happen the get the "Error: Cask adoptopenjdk8 exists in multiple taps:" error ...
  • Aditya Purandare
    Aditya Purandare almost 5 years
    This worked perfectly in Aug 2019. Steps: 1. brew tap adoptopenjdk/openjdk 2. brew cask installadoptopenjdk/openjdk/adoptopenjdk8
  • mok0
    mok0 over 4 years
    Great advice to install jenv, makes it a lot easier to manage several versions of java. I am always wary of zapping anything installed into macOS by Apple, and with jenv, you can keep everything nicely separated.
  • roottraveller
    roottraveller over 4 years
    $ brew cask install adoptopenjdk8 Error: Cask adoptopenjdk8 exists in multiple taps: caskroom/versions/adoptopenjdk8 adoptopenjdk/openjdk/adoptopenjdk8 . I have to use brew cask install adoptopenjdk/openjdk/adoptopenjdk8
  • rod
    rod over 4 years
    just to follow from @roottraveller previous comment. It appears as though the adoptopenjdk versions are now in the caskroom/versions tap as well. So you could just do brew tap caskroom/versions and brew cask install adoptopenjdk8, skipping the adoptopenjdk tap. Might be useful if you've already tapped and updated caskroom/versions.
  • xjlin0
    xjlin0 over 4 years
    brew tap homebrew/cask-versions and brew cask install adoptopenjdk8 works for me on Hi Sierra 10.13.6
  • theteddyboy
    theteddyboy over 4 years
    Thank you for this. This also solves the error in Catalina " Java for macOS 2017-001 can’t be installed on a disk. A newer version of this package is already installed.".
  • GensaGames
    GensaGames over 4 years
    @kavehmb Is there way to install it so without Sudo? Using above methods, it's trying to use usr/local/ space, even when I specified --appdir=~/Applications?
  • protoEvangelion
    protoEvangelion over 4 years
    brew cask install homebrew/cask-versions/adoptopenjdk8 worked for me
  • Josh Klein
    Josh Klein over 4 years
    Latest workaround requires brew tap adoptopenjdk/openjdk followed by brew cask install adoptopenjdk8. That may fail with "Error: Cask adoptopenjdk8 exists in multiple taps" because you already attempted this another way, so specify exact location with brew cask install adoptopenjdk/openjdk/adoptopenjdk8
  • Wijay Sharma
    Wijay Sharma over 4 years
    how do i set the JAVA_HOME path for the openjdk8??
  • Evan Zamir
    Evan Zamir over 4 years
    Once you have it installed and you want to set JAVA_HOME, where do you point it to?
  • Vittore Marcas
    Vittore Marcas over 4 years
    As @ kavehmb says, 1.$/usr/bin/ruby -e "$(curl -fsSL raw.githubusercontent.com/Homebrew/install/master/install)" $brew tap homebrew/cask-versions $brew update $brew tap adoptopenjdk/openjdk $brew cask install homebrew/cask-versions/adoptopenjdk8 (Or brew cask install adoptopenjdk/openjdk/adoptopenjdk8) That works for me on macOS 10.12.6 Sierra.
  • Vittore Marcas
    Vittore Marcas over 4 years
    +1, that works for me on macOS 10.12.6 Sierra. (Or brew cask install adoptopenjdk/openjdk/adoptopenjdk8)
  • Code Wiget
    Code Wiget over 4 years
    Ran these commands, but the wrong version of openjdk is on my machine: java --version openjdk 12.0.1 2019-04-16 OpenJDK Runtime Environment (build 12.0.1+12) OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
  • Rakesh Patil
    Rakesh Patil over 4 years
    If you have multiple versions of open jdk installed and want to change default version: /usr/libexec/java_home -V and then export JAVA_HOME='usr/libexec/java_home -v 1.8.0_232' used example version
  • Ray Garner
    Ray Garner over 4 years
    it always installs the latest version
  • tschumann
    tschumann over 4 years
    On reinstall I had to enter my password 300 times for it to reinstall properly - I guess I needed to give permission to overwrite a bunch of existing files.
  • viktorianer
    viktorianer about 4 years
    Best solution! Thank you!
  • amcc
    amcc about 4 years
    @EvanZamir export JAVA_HOME=`/usr/libexec/java_home`
  • glerYbo
    glerYbo about 4 years
    brew cask install adoptopenjdk8 doesn't need tapping.
  • glerYbo
    glerYbo about 4 years
    brew cask remove java; brew cask install adoptopenjdk8; java -version
  • emllnd
    emllnd about 4 years
    Thank you. Starts with short and to the point solution and continues with another useful tool: 'jenv' is handy to have around and is missing from most other answers. Helped with packaging Scala (2.12/2.13) code in 2020.
  • wasserholz
    wasserholz almost 4 years
    openJDK does not contain JavaFX
  • jeadonara
    jeadonara almost 4 years
    Works like a charm, brew cask install adoptopenjdk/openjdk/adoptopenjdk8
  • Dennis Jaheruddin
    Dennis Jaheruddin almost 4 years
    Presumably I did something wrong, but when trying to do java8 I got an error: Error: Cask 'java8' is unavailable: No Cask with this name exists.
  • Dennis Jaheruddin
    Dennis Jaheruddin almost 4 years
    +1 The first one failed (Error: No available formula with the name "homebrew/cask-versions/" ), but the second one seemed to work. Updated answer to avoid scaring people off with the first faillure.
  • Stevey
    Stevey almost 4 years
    This answer is odious. Just use brew cask install adoptopenjdk8.
  • Basil Bourque
    Basil Bourque almost 4 years
    @user3562927 Installing Homebrew (package manager) for the single goal of obtaining Java is like building a landing strip to park your car instead of just using your driveway. If you already have it, fine, use it. But suggesting Homebrew to those who simply need Java is poor advice. Apparently you are not the only easily-offended Homebrew fan, given the 5 down-votes left on this Answer without explanation. But I stand by my recommendation.
  • Corey
    Corey over 3 years
    @user924 how about this brew cask install adoptopenjdk8 ?
  • Ankit Khettry
    Ankit Khettry over 3 years
    This is the best answer indeed! Ideal for folks (like me) who have and need to manage multiple versions of java
  • Enihr
    Enihr over 3 years
    Adding this for people using newer mac versions Warning: The Ruby Homebrew installer is now deprecated and has been rewritten in Bash. Please migrate to the following command: /bin/bash -c "$(curl -fsSL raw.githubusercontent.com/Homebrew/install/master/install.sh‌​)"
  • Greenonline
    Greenonline over 3 years
    brew cask install java 8 gave me a completely different list: eclipse-java, netbeans-java-ee, oracle-jdk-javadoc, eclipse-javascript, netbeans-java-se
  • Arefe
    Arefe over 3 years
    Glad that helped you :)
  • timurb
    timurb over 3 years
    This no longer works. I have Homebrew 2.7.1 running on Mac OS Catalina 10.15.4 Using brew tap followed by brew install --cask from another comment apparently worked fine.
  • Daniel W.
    Daniel W. over 3 years
    @BasilBourque brew is more useful than you think. It installs a lot of software so much easier, your answer is a proof for that :-/
  • Basil Bourque
    Basil Bourque over 3 years
    @DanielW. The Question did not ask for a Brew solution, and did not even mention Brew. The Question asked about installing Java. There are several important issues to consider in installing Java; those issues I tried to cover. Apparently I have offended some Brew fans — that was not my intention. My intention was to pointedly address the Question at hand, as is the practice on Stack Overflow. And I stand by my position: Installing Brew just to install Java is overkill. Furthermore, using Brew to install Java will limit choices and ignore issues when it comes to various Java implementations.
  • Nakilon
    Nakilon over 3 years
    $ jenv add /usr/local/opt/openjdk@11 => ln: /Users/nakilon/.jenv/versions/openjdk64-11.0.9: No such file or directory. Ah, ok, needed to run those commands that are going to bash_profile.
  • freedev
    freedev over 3 years
    Have you run brew before jenv?
  • djb
    djb over 3 years
    I believe the first command (to install "the latest OpenJDK") be brew install --cask adoptopenjdk and not brew install --cask adoptopenjdk8 which will install JSK 8 not latest? also the latest is now 15 (as of Sep 2020). Also, Iit may help others to include brew tap adoptopenjdk/openjdk before the first command, as folks trying the install w/o the tap are getting errors.
  • mathandy
    mathandy about 3 years
    After following these steps, you may still need to define JAVA_HOME so it points to the brew installed java8. What worked for me was export JAVA_HOME=$(/usr/libexec/java_home -v1.8)
  • Muriithi Derrick
    Muriithi Derrick about 3 years
    should be the only accepted solution, works like charm.
  • Shams
    Shams almost 3 years
    this worked for me brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
  • eatSleepCode
    eatSleepCode almost 3 years
    How to install specific build of AdoptOpenJdk8
  • Memphis Meng
    Memphis Meng almost 3 years
    What's the point to install adoptopenjdk8~adoptopenjdk11 at one time?
  • Shivam
    Shivam almost 3 years
    the brew method worked also had to update the path variables
  • sourav pandit
    sourav pandit almost 3 years
    you need to run export PATH="/usr/local/opt/openjdk@8/bin:$PATH" after installing brew list for install packages brew info $package_name for information of package
  • freedev
    freedev almost 3 years
    @souravpandit thanks for the suggestion, I've just updated my answer ;)
  • sud007
    sud007 almost 3 years
    damn this was never this easy even on windows! no path setting, Android Studio ready right after just install. Best ever Java install on a new machine, specially Mac!
  • Akshay Vijay Jain
    Akshay Vijay Jain over 2 years
    what should be next command after searching?
  • pnv
    pnv over 2 years
    I think I messed up somewhere, after doing this, I got Unrecognized option: --version Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit., while trying to do java --version
  • freedev
    freedev over 2 years
    @pnv it’s a little weird. Maybe you have a mess with the PATH env, or many JDK installed in different ways. It’s hard to give you a hand from here.
  • Jose M Vidal
    Jose M Vidal over 2 years
    This is the one that worked for me today.
  • Basil Bourque
    Basil Bourque over 2 years
    Your first sentence is quite incorrect. Oracle provides two downloads of Java 8 Update 311: (a) the regular product Oracle JDK, and the cutting-edge new technology product, GraalVM Enterprise.
  • vpap
    vpap over 2 years
    brew install --cask adoptopenjdk/openjdk/adoptopenjdk8 worked for MacOS Monterey, 12.1. cask is no longer a brew command, see here, stackoverflow.com/questions/66286088/…
  • A. KUMAR
    A. KUMAR about 2 years
    brew install --cask adoptopenjdk/openjdk/adoptopenjdk8 worked for me, I am on a mac Monterey with Apple M1 chip.
  • Steven
    Steven about 2 years
    In order to test if the installation was successful run the following command on terminal 'javac -version'
  • aksyuma
    aksyuma about 2 years
    I'm getting this pop-up : ---------------------------- Stop! java 8.0.191-oracle is not available. Possible causes: * 8.0.191-oracle is an invalid version * java binaries are incompatible with your platform * java has not been released yet ----------------------------
  • stderr
    stderr about 2 years
    Indeed 8.0.191-oracle is not among the list anymore. You can use sdk list java to check other distributions
  • mdabdullah
    mdabdullah about 2 years
    This worked in 2022 , after installation the following commands can be used to validate your installation java , java -version . The commands java --version and which java do not give proper results though.
  • Hila Grossbard
    Hila Grossbard about 2 years
    as simple as that!
  • Rogier de Ruijter
    Rogier de Ruijter about 2 years
    Had to do brew install --build-from-source openjdk@8 to make it work
  • RRy
    RRy about 2 years
    2022: Mac 12.x : brew cask` is no longer a brew command. Use brew <command> --cask instead. brew install adoptopenjdk/openjdk/adoptopenjdk8 --cask