83

Installing java8 with Homebrew seems to no longer be working. After running:

brew install caskroom/cask/java8

I get the following error:

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

Simply doing:

brew cask install java8

Errors out with:

Error: Cask 'java8' is unavailable: No Cask with this name exists.

This seems like a recent development because I remember installing it this way a few months ago. Any suggestions on how to properly install java8 on MacOS nowadays?

1
  • this works: $ brew cask install adoptopenjdk Jan 6, 2020 at 1:18

13 Answers 13

142

New command is now :

brew install --cask homebrew/cask-versions/adoptopenjdk8

4
  • 1
    Doesn't work for me but this works as suggested by Corey - brew cask install homebrew/cask-versions/adoptopenjdk8
    – Jatin
    Jan 31, 2020 at 15:16
  • 9
    Updated command for me is brew install --cask homebrew/cask-versions/adoptopenjdk8
    – waffles
    Jan 4, 2021 at 19:12
  • That worked for me too uMdRupert - thank you! Feb 10, 2021 at 16:25
  • 1
    Me too, @uMdRupert. Sorry to add "me too!" but there's a lot of other stuff here to try. I had nearly given up before trying that one.
    – Sigfried
    Mar 1, 2021 at 10:56
31

This has already been answered as a github issue: https://github.com/Homebrew/homebrew-cask-versions/issues/7253

TLDR: the java8 artefact refers to the Oracle distribution, which has ceased being supported/available. If you really need java 1.8 instead of the latest versions you can take a look at AdoptOpenJDK/homebrew-openjdk.

2
  • Thanks. Is there any difference between the two? Sep 2, 2019 at 13:17
  • Presumably the oracle distribution could have proprietary additions, while the AdoptOpenJDK distribution is just a build of the open-source OpenJDK project.
    – Kiskae
    Sep 2, 2019 at 13:19
31

The command is now brew install homebrew/cask-versions/adoptopenjdk8 --cask

18

AdoptOpenJDK has been deprecated, and transitioned to Eclipse Temurin from Adoptium. See this blog post: https://blog.adoptopenjdk.net/2021/03/transition-to-eclipse-an-update/

To install Temurin Java 8, aka 1.8, with Homebrew, you can use:

brew tap homebrew/cask-versions
brew install --cask temurin8

If you already had AdoptOpenJDK installed using the commands in the other answers, you should uninstall it first, with:

brew uninstall --cask adoptopenjdk8

You can also download a .pkg for manual installation (the former link at AdoptOpenJDK now leads here): https://adoptium.net/?variant=openjdk8

13
brew install homebrew/cask-versions/adoptopenjdk8 --cask

In the latest changes of homebrew cask will have to be at the last.

3

For Homebrew 2.7.0. the brew cask commands are disabled

The command is now changed to

brew install --cask adoptopenjdk/openjdk/adoptopenjdk8

3

for new version use brew install --cask adoptopenjdk/openjdk/adoptopenjdk8

0
3

Although cask remove the support for JAVA8, we can still install JAVA8 using brew.

It requires the manual download of JAVA8.dmg and add the java8.rb which could be used by cask.

Machine: MAC

OS: Mojave (10.14.6)

JAVA version: java 8u231

Step-1

Download dmg file from Oracle Site. You require oracle account to download the same

Step-2

Start the HTTP server from the folder where you downloaded the dmg file. For me it's ~/Downlaods and I use python to start HTTP server:

python -m SimpleHTTPServer 8000

Step-3

Create file java8.rb in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks (where java.rb exist) and add the following:

cask 'java8' do
  version '8u231,b15:9eef341qase34d44fbaa21'
  sha256 'f808d11b34fa9ee7b6326b5b6dd18544496e02c84b839d94e062bd4493df5d45'

  url "http://localhost:8000/jdk-#{version.before_comma}-macosx-x64.dmg",
      cookies: {
                 'oraclelicense' => 'accept-securebackup-cookie',
               }
  name 'Oracle Java 8 Standard Edition Development Kit'
  homepage 'https://www.oracle.com/technetwork/java/javase/overview/index.html'

  depends_on macos: '>= :yosemite'

  pkg 'JDK 8 Update 231.pkg'

  uninstall pkgutil: "com.oracle.jdk#{version.before_comma}",
            delete:  [
                       '/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin',
                       '/Library/PreferencePanes/JavaControlPanel.prefPane',
                     ]

  zap trash: [
               '~/Library/Application Support/Oracle/Java',
               '~/Library/Application Support/com.oracle.java.JavaAppletPlugin.plist',
               '~/Library/Application Support/com.oracle.javadeployment.plist',
             ]

  caveats do
    license 'https://www.oracle.com/technetwork/java/javase/terms/license/javase-license.html'
  end
end


Step-4

Now, install using brew:

brew cask install java8

Note: I got the SHA-256 checksum from the above mentioned java download link. You will have to change the version number, sha256 and pkg sections to use the specific version you downloaded if it is not 8u231 like mine.

1
2

The command is

 brew cask install adoptopenjdk8-openj9

Fixed my problem and I can run my project in java8

java -version

openjdk version "1.8.0_222

OpenJDK Runtime Environment (build 1.8.0_222-b10)

Eclipse OpenJ9 VM (build openj9-0.15.1, JRE 1.8.0 Mac OS X amd64-64-Bit Compressed References 20190717_298 (JIT enabled, AOT enabled)

OpenJ9 - 0f66c6431

OMR - ec782f26

JCL - f147086df1 based on jdk8u222-b10)

2

For some of the newer version of operating system, We can use following command:

brew install --cask homebrew/cask-versions/adoptopenjdk8
0

I have only managed to uninstall it with homebrew like this:

brew uninstall --ignore-dependencies java

0
brew install homebrew/cask-versions/adoptopenjdk8 --cask

==> Caveats Temurin is the official successor to this software:

brew install --cask temurin8

adoptopenjdk8 has been officially discontinued upstream. It may stop working correctly (or at all) in recent versions of macOS.

Using sdkma, it is little bit easier

  1. Open a new terminal and enter curl -s “https://get.sdkman.io" | bash

  2. copy & paste the following in the terminal and enter source "$HOME/.sdkman/bin/sdkman-init.sh"

    It will install the SDKMAN in your machine.

  3. Check the version of the SDKMAN sdk version

  4. See the available Java versions offered by SDKMAN sdk list java

    It will show all the available JDK from different vendors with supported versions.

  5. Install parallel JDKs

install version 15: sdk install java 15.0.0-librca install version 8: sdk install java 8.0.265-librca

  1. Choose which one you want to use sdk use java 8.0.265-librca
-5

Ask the user to install Oracle JDK 8 instead of java8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.