How to install AdoptOpenJDK 8 LTS on macOS Big Sur 11.0.1

In this article we will see how we can install AdoptOpenJDK 8 on MacBook Pro running macOS Big Sur 11.0.1

Step1:

The first thing is to check if the package manager for Mac that is homebrew is installed or not. This can be done using the following command

brew --version

If you did not get the intended output, then you need to install HomeBrew. As of this writing HomeBrew 2.6.0 is the one which was available

For installation steps for HomeBrew please refer to the following page:

https://ourcodeworld.com/articles/read/1392/how-to-install-and-use-homebrew-in-macos-big-sur

Step2: 

Download the pkg file from the following URL(https://adoptopenjdk.net/releases.html?variant=openjdk8&jvmVariant=hotspot) and make sure you are selecting JDK 8 LTS.

Step3: 

Double click the pkg file to begin the installation. Java will be installed to the following location if everything goes well

/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

Step4: 

At the terminal verify if java is successfully installed by issuing

java  -version

javac -version

Step5: 

This step is about setting the JAVA_HOME environment variable which by default will not be done by the pkg installed.

  • Navigate to ~/.zshrc (Create the hidden file if it is not available already)
  • Add the following line
    export JAVA_HOME="/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"
  • Save the file and exit

Step6: 

Quit and reopen the terminal and type the following command

       echo $JAVA_HOME

       You should see the JAVA_HOME path which was set above which is

       /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

That's it! We are all set to run java code on Mac.

Comments