DEV Community

Ajeet Singh Raina for Docker

Posted on • Updated on

How to setup Java on Apple Mac M1 Pro

Java™ is the world's leading programming language and platform. The Adoptium Working Group promotes and supports high-quality, TCK certified runtimes and associated technology for use across the Java™ ecosystem. Eclipse Temurin is the name of the OpenJDK distribution from Adoptium.

The Eclipse Temurin binaries are provided at no cost to you by Adoptium to use, forever, under the terms of the "GNU General Public License, version 2 with the Classpath Exception". The Eclipse Temurin™ project provides code and processes that support the building of runtime binaries and associated technologies that are high performance, enterprise-caliber, cross-platform, open-source licensed, and Java SE TCK-tested for general use across the Java ecosystem.

Follow the below steps to get OpenJDK installed in your macOS 12.4 Monterey:

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode

Install OpenJDK

$brew install --cask temurin
Enter fullscreen mode Exit fullscreen mode

Install a specific version

$brew tap homebrew/cask-versions
$sudo softwareupdate --install-rosetta
$brew install --cask temurin8
$brew install --cask temurin11
Enter fullscreen mode Exit fullscreen mode

Verify if Java is installed

The package installer will put the JDK into this location:
/Library/Java/JavaVirtualMachines/temurin-17.jdk/

java --version
openjdk 18.0.1 2022-04-19
OpenJDK Runtime Environment Temurin-18.0.1+10 (build 18.0.1+10)
OpenJDK 64-Bit Server VM Temurin-18.0.1+10 (build 18.0.1+10, mixed mode)
Enter fullscreen mode Exit fullscreen mode

Discussion (0)