7

If I have Oracle Java SE JDK 8 installed on my mac, how can I upgrade to Open JDK 8 and be sure it will be used by default?

Motivation: Android build tools seem to need JDK 8, but according to the following links Oracle JDK 8 will not receive free updates after January 2019 for commercial use, not even security updates:

0

2 Answers 2

7

Recommended prerequisite: check which versions of Java may already be installed using the following command: /usr/libexec/java_home -V

The following commands worked for me:

  • brew search openjdk # check if desired adoptopenjdk8 cask may already available
  • brew search java # (optional)
  • brew tap AdoptOpenJDK/openjdk # (assuming that the desired adoptopenjdk8 cask is not already available)
  • brew search openjdk # check that the desired adoptopenjdk8 cask is now available
  • brew install --cask adoptopenjdk8

Then the following commands confirmed that I was using the desired OpenJDK 8 version by default (with no JAVA_HOME environment variable setting):

  • java -version
  • javac -version

And the following commands confirmed that I have both Java SE 8 and OpenJDK 8 installed:

  • /usr/libexec/java_home -V
  • ls /Library/Java/JavaVirtualMachines

Note that which java and which javac show that java and javac are still run from /usr/bin.

Followup step: remove the old Java SE SDK from /Library/Java/JavaVirtualMachines, as documented in: https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096903

AdoptOpenJDK 8 package notes May 2019: adoptopenjdk8 was also added to homebrew/cask-versions, and this led to some issues: https://github.com/AdoptOpenJDK/homebrew-openjdk/issues/106

There is now a proposal to rename adoptopenjdk8 to openjdk8 in homebrew/cask-versions: https://github.com/Homebrew/homebrew-cask-versions/pull/7375

If this proposal is merged, this answer will likely be updated to recommend installing the renamed cask.

See also (some references):

0

Use the adoptopenjdk cask

See also https://discourse.brew.sh/t/how-to-install-openjdk-with-brew/712/4

To install latest:

brew install --cask adoptopenjdk

To install a specific version

brew tap AdoptOpenJDK/openjdk
brew install --cask adoptopenjdk8
brew install --cask adoptopenjdk9

Manual Solution

If you are looking to just bring down the binary without actually installing it, simply navigate to https://adoptopenjdk.net

Resources: How can I install java openjdk 8 on High Sierra

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .