Java 17 is the LDS - Long Term Support version released to the public in September 2021. If you want to install Java 17 JDK natively on have multiple options,
We will the installing the Oracle OpenJDK 17 using brew, it will by default pick the ARM 64 bit version.
How to install Brew on M1/M2 Mac
Brew Command:brew install openjdk@17
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/17/manifests/17.0.4.1
...
...
If you need to have openjdk@17 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zshrc
For compilers to find openjdk@17 you may need to set:
export CPPFLAGS="-I/opt/homebrew/opt/openjdk@17/include"

If you want to use JDK 17 as the default, you will need to add it to the PATH in .zshrc file (both java and javac)
% echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zshrc
% export CPPFLAGS="-I/opt/homebrew/opt/openjdk@17/include"
After setting the path, you can check if it took effect by reloading the zsh shell (just type zsh on prompt) and running the version commands,
% java -version
openjdk version "17.0.4.1" 2022-08-12
OpenJDK Runtime Environment Homebrew (build 17.0.4.1+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.4.1+0, mixed mode, sharing)
% javac -version
javac 17.0.4.1
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!