Take a look at how you can quickly get started with OpenJDK with this tutorial that gives you commands for installing version 7-11 through a Mac Terminal.
Join the DZone community and get the full member experience.
Join For Free- First, Download a binary distribution of Groovy and unpack it into some file on your local file system. Set your GROOVYHOME environment variable to the directory you unpacked the distribution. Add GROOVYHOME/bin to your PATH environment variable. Set your JAVAHOME environment variable to point to your JDK. On OS X this is /Library/Java/Home, on other unixes.
- Install Java 7 and 8. People on the Stackoverflow cautioned not to install 8 until 7 is installed. So we are going to install JDK 7 first. Unlike other version managers such as NVM, jEnv itself doesn’t install JDKs. You have to do it yourself. Luckily, Homebrew Cask made this task really easy.
In this article, I will be using Homebrewto install OpenJDK versions on the Mac.
Homebrew complements macOS (or your Linux system). Install your RubyGems with gem and their dependencies with brew. “To install, drag this icon” no more. Homebrew Cask installs macOS apps, fonts and plugins and other non-open source software. $ brew install-cask firefox. Download the DMG file of JDK-7 from here; Click on DMG and follow the instructions. It will install and configure JDK-7 on mac. Now in your android studio go to File-Project Structure - SDK Location. In JDK location click on browse and go to /-Library-Java-JavaVirtualMachines-jdk1.7.060.jdk-Contents-Home. Java SE 7 Archive Downloads.
Mac Brew Install Jdk
We use brew install
to install JDK versions 8,9,10, andbrew cask install
for version 11 and above.
All the brew commands are executed in the Terminal window on the Mac.
Install OpenJDK Versions 8, 9, and 10
brew tap AdoptOpenJDK/openjdk
brew search /adoptopenjdk/
The Formulae section contains the identifiers for the various JDK versions.
To install a specific JDK version: brew install <identifier>
e.g. to install OpenJDK 8: brew install adoptopenjdk/openjdk/adoptopenjdk-openjdk8
JAVA_HOME should be set by the developer to /usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11.
Install OpenJDK Version 11
brew cask install adoptopenjdk
JAVA_HOME should be set by the developer to /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk.
Opinions expressed by DZone contributors are their own.