Java 19 is currently the latest version of Java. Even though it isn’t a LTS release, it’s worth installing it so we can test new features. In one of the previous articles I have written about how to install it on MacOS. In this article I will show you how to install JDK 19 on Windows, add it to the path and to setup IntelliJ IDEA so you can write Java applications against it.

First you have to visit . Near the top you’ll see build number and download links for various operating systems. For the Windows choose (obviously) Windows/x64 zip file. JDK 19 download page

The archive already contains a directory, in this case jdk-19.0.1: JDK 19 archive

After the file finished downloading we have to unpack it somewhere. Since I have a few JDKs I keep them all under the same parent directory, in my case c:\Programs\, under which I have subdirectories for JDK11, JDK 17 etc. After unpacking the archive into c:\Programs\, you should see a directory structure similar to this one:

 1PS C:\Programs\jdk-19.0.1> dir
 3    Directory: C:\Programs\jdk-19.0.1
 5Mode                 LastWriteTime         Length Name
 6----                 -------------         ------ ----
 7d----           11/5/2022  8:06 PM                bin
 8d----           11/5/2022  8:06 PM                conf
 9d----           11/5/2022  8:06 PM                include
10d----           11/5/2022  8:06 PM                jmods
11d----           11/5/2022  8:06 PM                legal
12d----           11/5/2022  8:06 PM                lib
13-a---           9/14/2022  2:03 PM           1244 release

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

1PS C:\Programs\jdk-19.0.1> cd bin
2PS C:\Programs\jdk-19.0.1\bin> ./java -version
3openjdk version "19.0.1" 2022-10-18
4OpenJDK Runtime Environment (build 19.0.1+10-21)
5OpenJDK 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

We see that the JDK reported version 19 so the installation succeeded!

Setting JAVA_HOME environment variable

Now there is a question whether you should set JAVA_HOME environment variable to point to the JDK 19. Java 19 is not a LTS version so there is a chance you don’t want JAVA_HOME to point to it but rather to the JDK 17 (or even JDK 11). But for completeness, here is the procedure.

Open Control Panel, click User Accounts and then click Change my environment variables on the left. A new window titled Environment Variables will open, like in the image: Environment Variables

Now there are two possibilities: either you already have JAVA_HOME set (like I do) or you don’t. If you have it set, click Edit… and enter c:\Programs\jdk-19.0.1 as a value (or the directory where you have unpacked JDK 19). If you don’t have it set, click New… and enter JAVA_HOME for Variable name and c:\Programs\jdk-19.0.1 for Variable value (or the directory where you have unpacked JDK 19), like in the image below: Set JDK 19 for JAVA_HOME

Click OK and you should be back to the Environment Variables window. The last step is to add Java to your path.

Adding JDK 19 to PATH

Find variable called Path in the upper pane of the Environment Variables window. Click Edit… and check if you already have a value %JAVA_HOME%\bin. If not, add it and click OK: Add Java to PATH

Click OK until you close all the dialogs and close Control Panel. Now open PowerShell prompt and type java -version to see if Java 19 became the default Java version for you. You should see that it is:

1PS C:\Users\ivan> java -version
2openjdk version "19.0.1" 2022-10-18
3OpenJDK Runtime Environment (build 19.0.1+10-21)
4OpenJDK 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

Adding JDK 19 to IntelliJ IDEA

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

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

Click on the + select Add JDK… and IntelliJ will ask you to select home directory for JDK. Choose the dir into which you have unpacked JDK (e.g. c:\Programs\jdk-19.0.1) 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 Windows. Until next time, TheJavaGuy saluts you!