How To Install Java 17 On Mac

How To Install Java 17 On Mac

It provides all the steps required to install Java 17 on Mac systems including macOS Sierra, High Sierra, Mojave, Catalina, and Big Sur.

September 26, 2021

This tutorial provides all the steps required to install Oracle JDK 17 on Mac systems. It provides the steps required to install Java 17 on macOS Catalina. The steps should be the same for other versions of macOS including Sierra, High Sierra, Mojave, and Big Sur.

Notes: The Java 17 is an LTS version which means there will be long-time support from Oracle for the same. The premier support will be available till September 2026 and extended support will be available till September 2029.

System Checks

In this step, we will test whether Java is already installed or not. To do so, open the terminal and type java -version as shown in Fig 1. If Java is already installed on the system, it will show the active version details as shown in Fig 1.

Install Oracle Java 17 or JDK 17 on macOS - Check Version

Fig 1

It might show the message - "No Java runtime present, requesting install" in absence of Java and also opens a dialog to know more about it as shown in Fig 2.

Install Oracle Java 17 or JDK 17 on macOS - Warning

Fig 2

Now press the OK Button to hide the dialog.

Download Java 17

Open the download link to select the available versions as shown in Fig 3.

Install Oracle Java 17 or JDK 17 on macOS - Download Options

Fig 3

Click the Download Option as highlighted in Fig 3.

Install Java 17

Double click the DMG file downloaded in the previous step to start installing Oracle JDK 17 on Mac. It will mount the DMG disk and shows the installer as shown in Fig 4. Make sure that you have gone through the updated License Agreement of Oracle JDK.

Install Oracle Java 17 or JDK 17 on macOS - Mount DMG

Fig 4

Now double-click the installer to start installing Java 17 on Mac. The installer shows the Welcome Screen as shown in Fig 5.

Install Oracle Java 17 or JDK 17 on macOS - Welcome Screen

Fig 5

Click the Continue Button to start the installation. It provides options to choose the installation type as shown in Fig 6.

Install Oracle Java 17 or JDK 17 on macOS - Installation Type

Fig 6

You may change the installation location by clicking the Go Back Button. It did not allow me to change the installation location on macOS Catalina. Now click the Install Button to start installing Java 17 on Mac. It also asks for permission to complete the installation as shown in Fig 7.

Install Oracle Java 17 or JDK 17 on macOS - Installation Permission

Fig 7

It shows the success message after completing the installation as shown in Fig 8.

Install Oracle Java 17 or JDK 17 on macOS - Installation Success

Fig 8

Now unmount the DMG image by right-clicking it as shown in Fig 9.

Install Oracle Java 17 or JDK 17 on macOS - Unmount Installer

Fig 9

We can check the JDK version to confirm the installation as shown in Fig 10.

Install Oracle Java 17 or JDK 17 on macOS - Check Version

Fig 10

This is all about installing Oracle JDK 17 on Mac systems including macOS Sierra, High Sierra, Mojave, Catalina, and Big Sur.

Switch JDK

It might be required to switch the active Java in case multiple JDKs are installed on the same Mac machine. You can follow How To Switch Java Version On Mac.

Getting started with Java - Hello World

In this step, we will write, compile, and execute our first program in Java using the standard Hello World example.

Now write the first Java program as shown below, save the program as HelloWorld.java and exit the editor. Make sure that the class name and file name are the same.

class HelloWorld {

public static void main( String[] args ) {

System.out.println( "Hello World !!" );
}
}

Now open the command prompt and navigate to the path where you have saved your Java program. Use the below-mentioned commands to compile and execute the program.

# Compile - Specify file name and extension
javac HelloWorld.java

# Execute - Spicy file name
java HelloWorld

# Output
Hello World !!

These are the easy to install steps required to install Oracle JDK on Mac and write, compile and execute the first Java program.

Summary

This tutorial provided all the steps required to install Oracle JDK 17 on Mac and also provided the steps required to compile and run the first Java program using a simple Hello World program.

Write a Comment
Click the captcha image to get new code.
Discussion Forum by DISQUS