Skip to main content

macOS

Using Homebrew

If you have Homebrew installed.

Install OpenJDK 17.

brew install openjdk@17

Create a symbolic link to make Java available system-wide.

sudo ln -sfn $(brew --prefix)/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk

Verify installation

java -version

Using the Official Oracle Installer

  1. Visit the Oracle Java Downloads page
  2. Download the macOS installer (.dmg) for Java 17
  3. Open the downloaded .dmg file and follow the installation instructions
  4. Verify the installation by opening Terminal and running:
java -version

Using SDKMAN

If you have SDKMAN installed:

First, list available Temurin 17 builds to find the current version identifier:

sdk list java | grep tem | grep "17\."

Then install using the identifier from the output (e.g. 17.0.x-tem):

sdk install java 17.0.x-tem
java -version

Setting JAVA_HOME

Add the following to your ~/.zshrc or ~/.bash_profile file (depending on your shell):

For Homebrew installation.

export JAVA_HOME=$(/usr/libexec/java_home -v 17)

Or specify the path directly (adjust according to your installation).

# export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home

Then reload your shell configuration:

For Zsh:

source ~/.zshrc

For Bash:

source ~/.bash_profile

Verify JAVA_HOME is set correctly:

echo $JAVA_HOME