Goglides Dev 🌱

Balkrishna Pandey
Balkrishna Pandey

Posted on • Originally published at pandeybk.Medium on

Installing a specific version of Java on my Macbook Pro

As the title said, this is merely a placeholder for information that I may require in the future. On the internet, there are several articles on this subject. However, I have to use Google to make it work every time, which is odd. I can’t just recall the information or locate the appropriate articles without first skimming through a few.

Some information

brew --version
Homebrew 3.2.11-163-gf14fcc8
Homebrew/homebrew-core (git revision a3d1c526759; last commit 2021-09-14)
Homebrew/homebrew-cask (git revision 51f858fec1; last commit 2021-09-14)
Enter fullscreen mode Exit fullscreen mode

Install with HomeBrew

  1. Update HomeBrew.

brew update

  1. Add the casks tap.
$ brew tap homebrew/cask-versions
Enter fullscreen mode Exit fullscreen mode
  1. Install a specified JDK version, such as java8, java11, or java.
$ brew install java11
Enter fullscreen mode Exit fullscreen mode

Follow the steps so that you can find it later,

For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

openjdk@11 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have openjdk@11 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc

For compilers to find openjdk@11 you may need to set:
  export CPPFLAGS="-I/usr/local/opt/openjdk@11/include"
Enter fullscreen mode Exit fullscreen mode


java --version
openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment Homebrew (build 11.0.12+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)