How to Install Java on Mac

Master Java on Mac

How to Install Java on Mac

How to Install Java on Mac

Java, an object-oriented programming language, utilizes a platform-independent model through virtual machines for application development. It enables Java applications to be executed on Java Virtual Machines (JVM) irrespective of the operating system in use.

Development and deployment of Java-based applications and applets leverage a software development environment known as the Java Development Kit (JDK). Included within the JDK is the Standard Edition of the Java API, alongside a suite of components for Java application execution, referred to as the Java Runtime Environment (JRE).

This guide will walk you through the steps for installing both the Java Development Kit (JDK) and the Java Runtime Environment (JRE) on a macOS system.


  • A macOS system version 10.7.3 or higher.

System administrative privileges.

Installing Java on macOS

  • There are several builds of the Java Development Kit available for download and installation. The original Oracle JDK is maintained by Oracle, offering a closed source version, while simultaneously contributing to the development of OpenJDK, the open source variant.

This guide will cover the installation process for both the Oracle JDK and OpenJDK on macOS, noting that the primary distinctions between them lie in their licensing terms.

It is important to mention that since OpenJDK is open source, it is developed by various contributors including Microsoft, Azul, and Red Hat, among others.

Installing Oracle JDK on macOS

To install Oracle’s Java Development Kit (JDK) on your Mac, you can follow the steps outlined below. This process involves downloading the official installer from Oracle’s website and executing it on your macOS system.

  • Navigate to the Java Downloads page on Oracle’s website.
  • Locate the macOS tab, and select the DMG installer that matches your Mac’s processor type:
    • For M1 or M2 Mac models, opt for the Arm 64 installer.
    • For Intel-based Mac models, select the x64 installer.
  • After downloading, open the DMG file and execute the PKG file contained within.
  • On the initial screen of the installer, click on the Continue button.
  • In the next window, click on Install to initiate the installation process.
  • You will be asked for your administrative password. Enter it to authorize the installation of the JDK.
  • Allow the installer to complete the file transfer. Once done, click Close to exit the installer.
  • To verify the successful installation of the JDK, open the Terminal and type the following command: java -version
  • This command will display the installed version of Java, confirming that the JDK has been installed correctly on your macOS system.

Installing OpenJDK via Homebrew on macOS

For those looking to install OpenJDK on macOS, leveraging Homebrew is an efficient method. OpenJDK is an open-source and production-grade version of Oracle’s JDK, offering the same functionalities without the commercial license.

To install OpenJDK using Homebrew, follow these steps:

  • Begin by updating Homebrew’s package database with the command:
  • sql
  • brew update
  • Next, install OpenJDK by specifying the version you need with the command:
  • kotlin
  • brew install openjdk@[version]
  • Replace [version] with the OpenJDK version you desire. For instance, to install OpenJDK 18, use:
  • css
  • brew install openjdk@18

Installing the Java Runtime Environment (JRE) on macOS

If your requirements are limited to running Java applications without the need for a full development kit, installing just the Java Runtime Environment (JRE) is sufficient.

To install the JRE, follow these instructions:

  • Visit the official Java website.
  • Look for and click the “Download Java” button.
  • On the following page, press the “Download Java” button again to initiate the download of the DMG installer.
  • Open the downloaded DMG file and double-click the installer package inside.
  • Click “Install” in the installer window and authenticate as necessary to commence the installation.
  • Once the installation completes, click “Close” to exit the installer.

By following these steps, you can easily install either OpenJDK with Homebrew or the JRE directly from Java’s website on your macOS system, depending on your specific needs.

Leave a Reply

Your email address will not be published. Required fields are marked *