Core Java

Install OpenJDK on Linux, macOS, Windows

The Oracle JDK is available for free download and personal use, but it now imposes strict licensing terms for commercial or shared usage. In such cases, it’s recommended to opt for OpenJDK. Though OpenJDK lacks installers for all platforms, its open-source nature allows for community contributions to fill these gaps. Various installer-based packages for OpenJDK are available, with Amazon notably offering timely releases under the Corretto brand. Let us delve into understanding how to install OpenJDK on Linux, macOS, and Windows machines.

1. Installing OpenJDK Corretto on Linux

Before you begin, ensure you have administrative privileges on your Linux system. It’s also recommended to have a basic understanding of the Java Development Kit (JDK) and the command-line interface.

Let us proceed with the process of installing OpenJDK Corretto on a Linux system.

  • Open a terminal window.
  • Update the package index to ensure you have the latest package information:
    sudo apt update
    
  • Install the OpenJDK Corretto package using the following command:
    sudo apt install -y java-1.8.0-amazon-corretto-devel
    

    Replace 1.8.0 with the desired Java version if you’re installing a different version of Corretto.

1.1 Testing the Installation

To ensure that OpenJDK Corretto is correctly installed, open a terminal window and enter the following command:

java -version

If OpenJDK Corretto is installed properly, the terminal should display the installed Java version, confirming the successful installation. Once done you will be able to develop and run the Java applications.

2. Installing OpenJDK Corretto on macOS

Before you begin, make sure you have administrative privileges on your macOS system. It’s also recommended to have a basic understanding of the Terminal and command-line interface.

Let us proceed with the process of installing OpenJDK Corretto on a macOS system.

  • Open the Terminal application on your macOS system.
  • Install Homebrew, a package manager for macOS, if you haven’t already. You can install Homebrew by running the following command:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  • Update Homebrew to ensure you have the latest package information:
    brew update
    
  • Install OpenJDK Corretto using Homebrew:
    brew install --cask adoptopenjdk8
    

    This command installs the AdoptOpenJDK 8 version, which is based on OpenJDK Corretto. You can replace 8 with a different version number if needed.

2.1 Verification Steps

  • To verify that OpenJDK Corretto is installed correctly, open a new Terminal window or restart your current session to apply the changes.
  • Run the following command to check the installed Java version:
    java -version
    

    If OpenJDK Corretto is installed properly, the Terminal should display the installed Java version along with other relevant information.

3. Installing Amazon Corretto on Windows

Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Follow these steps to install Corretto on a Windows system:

3.1 Download Amazon Corretto

Visit the Amazon Corretto website and download the version of Corretto appropriate for your system. Choose between the latest LTS release or the latest version.

3.2 Install Amazon Corretto

  • Once the download is complete, locate the downloaded executable file (.msi).
  • Double-click on the executable file to begin the installation process.
  • Follow the on-screen instructions provided by the installer.
  • Choose the installation directory if prompted.
  • Complete the installation process.

3.3 Verify the Installation

To verify that Amazon Corretto has been successfully installed on your Windows system, follow these steps:

  • Open Command Prompt by searching for it in the Windows Start menu.
  • Type the following command and press Enter:
    java -version
    

    If Corretto has been installed correctly, you should see an output similar to the following:

    openjdk version "11.0.12" 2022-07-19
    OpenJDK Runtime Environment Corretto-11.0.12.7.1 (build 11.0.12+7-LTS)
    OpenJDK 64-Bit Server VM Corretto-11.0.12.7.1 (build 11.0.12+7-LTS, mixed mode, sharing)
    

    This output indicates that Amazon Corretto version 11.0.12 is installed on your system.

4. Conclusion

In conclusion, we’ve covered the installation process of Amazon Corretto, a versatile distribution of the Open Java Development Kit (OpenJDK), across various operating systems. Whether you’re on Linux, macOS, or Windows, the steps are straightforward and accessible. On Linux, users can leverage package managers like yum or apt-get to easily install Corretto. For macOS users, the Homebrew package manager streamlines the installation process. Lastly, on Windows, users can download and execute the installer, following simple on-screen instructions. Regardless of the operating system, verifying the installation ensures that Corretto is properly set up and ready for Java development tasks. With Corretto installed, developers can enjoy a no-cost, production-ready JDK that offers long-term support and compatibility with Java applications.

Yatin Batra

An experience full-stack engineer well versed with Core Java, Spring/Springboot, MVC, Security, AOP, Frontend (Angular & React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button