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"
![Installing JDK 17 on M1 or M2 Mac Installing JDK 17 on M1 or M2 Mac](https://code2care.org/java/install-java-17-jdk-arm-based-m1-m2-mac/images/Installing JDK 17 on M1 or M2 Mac.jpg)
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
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- Fix: grunt: command not found (Mac/Windows)
- AppleScript Example with TextEdit
- How to copy Password of Wifi on your Mac
- Install OpenJDK Java (8/11/17) versions using brew on Mac (Intel/M1/M2)
- How to check if a port is in use using terminal [Linux or macOS]
- Cut, Copy and Paste Keyboard Shortcuts on Mac Keyboard
- [macOS] NetBeans IDE cannot be installed. Java (JRE) found on your computer but JDK XX or newer is required.
- How to Remove Widgets from macOS Sonoma 14 Desktop
- Turn off Auto-Capitalization on macOS Ventura 13
- How to Go To /usr/local/bin on Mac Terminal?
- How to Open TextEdit on Mac
- Mac: How to Open Android Studio from Terminal
- How to change the default location of Mac Screenshot
- Display Seconds in Digital Clock on Mac Menu Bar [macOS]
- How to install homebrew (brew) on M1 Mac
- Must Know Homebrew Commands for Mac/Linux Users
- Steps to Uninstall Roblox on Mac (macOS)
- How to change the System Settings Sidebar icon size Mac Ventura 13
- How to set Out Of Office (OOO) on Outlook for Mac [Updated 2023]
- Trigger Notification Center Message using Mac Terminal Command
- [fix] macOS Ventura - Python3 xcrun: error: invalid active developer path missing xcrun at CommandLineTools
- How to Install Rust Language on Mac (macOS)
- How to minimize all Windows in Mac
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS]
- How to make TextEdit the default text Editor on Mac
- Right Align Text in Bootstrap framework - Bootstrap
- [Solved] SharePoint Access Denied error editing Document Name - SharePoint
- Brew Error - This command updates brew itself and does not take formula names - HowTos
- How to run a Maven jar project from eclipse without tomcat - Eclipse
- [git] fatal: your current branch 'main' does not have any commits yet - Git
- How to represent an Enum in Python Programming - Python
- How to take screenshot on Android - Android
- Fail to connect to camera service Android java RuntimeException - Android