Zubora Code

Install Java on macOS at lightning speed

I will show you the steps to install Java on macOS at lightning speed.

Published: 25 August, 2023
Revised: 25 August, 2023

Overview

This document outlines the process of quickly installing Java on a Mac. Since I frequently use Java for work and have tried various installation methods, I personally find using SDKMan the most convenient, especially considering future version management. So, in this instance, I will also use SDKMan.

My environment

Device

Mac mini

Chip

Apple M2 Pro

macOS

Ventura 13.5


Installing SDKMan

As shown below:

https://sdkman.io/install

$ curl -s "https://get.sdkman.io" | bash
$ source .zshrc
$ sdk version
SDKMAN!
script: 5.18.2
native: 0.4.2

Installing Java

Relevant commands can be found here:

https://sdkman.io/usage

Check the list of installable Java versions:

$ sdk list java
================================================================================
Available Java Versions for macOS ARM 64bit
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 Corretto      |     | 20.0.2       | amzn    |            | 20.0.2-amzn
               |     | 20.0.1       | amzn    |            | 20.0.1-amzn
               |     | 17.0.8       | amzn    |            | 17.0.8-amzn
               |     | 17.0.7       | amzn    |            | 17.0.7-amzn
               |     | 11.0.20      | amzn    |            | 11.0.20-amzn
               |     | 11.0.19      | amzn    |            | 11.0.19-amzn
               |     | 8.0.382      | amzn    |            | 8.0.382-amzn
               |     | 8.0.372      | amzn    |            | 8.0.372-amzn
...

Despite various options, as of August 2023, it's advisable to go with the latest LTS (Long Term Support) version, which is 17, and select Adoptium (Temurin).

$ sdk install java 17.0.8-tem
$ java -version
openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment Temurin-17.0.8+7 (build 17.0.8+7)
OpenJDK 64-Bit Server VM Temurin-17.0.8+7 (build 17.0.8+7, mixed mode)
$ echo $JAVA_HOME
/Users/tkugimot/.sdkman/candidates/java/current

That's all! Thank you very much for your hard work!


Toshimitsu Kugimoto

Software Engineer

Specializing in backend and web frontend development for payment and media at work, the go-to languages for these tasks include Java and TypeScript. Additionally, currently exploring Flutter app development as a side project.