Installing Amazon Corretto 21 on macOS

Learning Objectives:

By the end of this lesson, you will be able to:

  • Download the correct Amazon Corretto 21 package for macOS
  • Install Amazon Corretto 21 on your macOS system
  • Configure essential environment variables for Java development
  • Verify the successful installation of Amazon Corretto 21

Step 1: Download Amazon Corretto 21

  1. Open your web browser and go to the Amazon Corretto download page for macOS: https://corretto.aws/downloads/latest/amazon-corretto-21-x64-macos-jdk.pkg
  2. The download should start automatically. If it doesn't, click on the link on the page to begin downloading the .pkg file for the latest version of Corretto 21.

Step 2: Install Amazon Corretto 21

  1. Once the download is complete, locate the .pkg file in your Downloads folder.
  2. Double-click the file to start the installation wizard.
  3. Follow the prompts in the installation wizard. You may need to enter your system password to allow the installation.
  4. The default installation location will be /Library/Java/JavaVirtualMachines/.

Step 3: Set Up Environment Variables After installation

Open your shell configuration file (e.g., .bash_profile for Bash or .zshrc for Zsh) using a text editor. For example:

Add the following lines at the end of the file:

Save the file and exit the editor and reload your shell configuration:

You should see output similar to this:

To verify that Amazon Corretto 21 has been installed successfully, run:

This output confirms that Amazon Corretto 21 is installed and ready to use on your system.

Congratulations! You've successfully installed Amazon Corretto 21 on your macOS. This Java Development Kit provides you with all the tools you need to start writing, compiling, and running Java programs.

Summary:

In this lesson, we've walked through the process of installing Amazon Corretto 21 on macOS. We've covered downloading the installer, running the installation package, setting up essential environment variables, and verifying the installation. By following these steps, you've set up a robust Java development environment that will serve you well as you embark on your Java programming journey.

Complete and Continue