Blog

How to install Java 19 (OpenJDK 19) on MacOS

The easiest way to install Java 19 (OpenJDK 19) on MacOS

Java 19 is currently the latest version of Java. Even though it isn’t an LTS release, it’s worth installing it so we can test new features. In this article I will show you how to install JDK 19 on MacOS and to set up IntelliJ IDEA so you can write Java applications against it.

First, you have to visit https://jdk.java.net/19/. Near the top you’ll see the build number and download links for various operating systems. If you have a new M1 Mac, choose macOS/AArch64; otherwise, choose macOS/x64. After the file finishes downloading, we have to unpack it because it’s a gzipped tar file. JDK 19 download page

Since I have a few JDKs, I keep them all under the same parent directory, in my case ~/jdk. Unpack the JDK by opening your terminal (such as iTerm2, kitty, Terminal…), going to the directory where you saved the JDK .tar.gz file, and typing tar -zxf openjdk-19_macos-x64_bin.tar.gz -C ~/jdk. After doing this, if you go to the dir where you unpacked the JDK (again, in my case it’s ~/jdk), you should see a directory structure very similar to this one:

ivanmilosavljevic @ TJG in ~/jdk [13:53:18]
$ tree -d -L 4
...
├── jdk-18.jdk
│   └── Contents
│       ├── Home
│       │   ├── bin
│       │   ├── conf
│       │   ├── include
│       │   ├── jmods
│       │   ├── legal
│       │   └── lib
│       ├── MacOS
│       └── _CodeSignature
├── jdk-19.jdk
│   └── Contents
│       ├── Home
│       │   ├── bin
│       │   ├── conf
│       │   ├── include
│       │   ├── jmods
│       │   ├── legal
│       │   └── lib
│       ├── MacOS
│       └── _CodeSignature
...

58 directories

The most important files are in the bin directory, so let’s verify that the proper version is installed there:

# ivanmilosavljevic @ TJG in ~/jdk [13:54:05]
$ cd jdk-19.jdk/Contents/Home/bin

# ivanmilosavljevic @ TJG in ~/jdk/jdk-19.jdk/Contents/Home/bin [13:54:07]
$ ./java -version
openjdk version "19" 2022-09-20
OpenJDK Runtime Environment (build 19+36-2238)
OpenJDK 64-Bit Server VM (build 19+36-2238, mixed mode, sharing)

We see that the JDK reported version 19 (build 19+36-2238), so the installation succeeded! If you have multiple projects that use different versions of Java, the easiest way to manage them is to use the excellent jEnv. I have an entire article explaining how senior developers manage multiple JDKs with jEnv.

Now let’s see how you can use this JDK from IntelliJ IDEA.

In IntelliJ, open any Java project (or create a new one) and go to File/Project Structure. In the Project Structure window, choose Platform Settings/SDKs and click on the + sign at the top. adding new SDK in IntelliJ IDEA

Choose Add JDK… and IntelliJ will ask you where your JDK is. Then select the path ~/jdk/jdk-19.jdk/Contents/Home, and you should see JDK 19 added to your IntelliJ. Click OK and it’s done! You’ve successfully added JDK 19 to IntelliJ IDEA. JDK 19 added to IntelliJ IDEA

Dear fellow developer, thank you for reading this article about installing JDK 19 on MacOS. Until next time, TheJavaGuy salutes you 👋!

Found this useful? Pass it along:

© 2022-2026 Ivan Milosavljević (TheJavaGuy)

Built with Astro using modified Astrofy template