Step-by-step Guide to Install Java 11 OpenJDK Development Environment

Introduction

Java is an object-oriented programming language created by Sun Microsystems (which has since been acquired by Oracle). It’s used to develop applications for multiple platforms, including Windows, MacOS, and Linux. Java 11 is the current version of Java, and it’s been optimized for better performance and stability than previous versions. OpenJDK is an open source implementation of the Java platform. It’s freely available for download and use, allowing developers to access the latest version of Java to create their applications. This guide will walk through the steps needed to install the OpenJDK 11 development environment on your local system.

Prerequisites

Before you begin, make sure you have the following installed and setup:

  • A Linux or MacOS system
  • Apache Maven 3.2 or later
  • NetBeans IDE 8.1 or later
  • JDK 1.8 or higher

Step 1: Install OpenJDK

The first step is to install the OpenJDK 11 version on your machine. This version is available for download from the AdoptOpenJDK website.

On MacOS:

  • Download the AdoptOpenJDK package from this link.
  • Ensure that the package is saved to your "/Applications" directory.
  • Open the terminal and enter the following command to install the package:
    $ sudo installer -pkg "/Applications/OpenJDK11U-jdk_x64_mac_hotspot_11.0.7_10.pkg" -target /

On Linux:

  • Download the AdoptOpenJDK package from this link.
  • Ensure that the package is saved on a directory that you have access to.
  • Open the terminal and enter the following command depending on your architecture.

For x86_64:
$sudo yum install "/path/to/OpenJDK11U-jdk_x64_linux_hotspot_11.0.7_10.tar.gz"

For aarch64:
$sudo yum install "/path/to/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.7_10.tar.gz"

Step 2: Set up the Environment Variable

The next step is to set up the JAVA_HOME environment variable. This allows the Java compiler to find the directory where Java is installed.

On MacOS:

  • Open the terminal and enter the following command to open the ".bash_profile" file:
    $ nano ~/.bash_profile
  • Once the file is open, enter the following:
    export JAVA_HOME=$(/usr/libexec/java_home)
  • Save the file and then enter the following command to let the changes take effect:
    source ~/.bash_profile

On Linux:

  • Open the terminal and enter the following command to open the "bashrc" file:
    $ nano ~/.bashrc
  • Once the file is open, enter the following:
    export JAVA_HOME=$(/usr/lib/jvm/java-11-openjdk-amd64)
  • Save the file and then enter the following command to let the changes take effect:
    source ~/.bashrc

Step 3: Install Apache Maven

The next step is to install Apache Maven. This is a build automation tool used for Java applications.

On MacOS:

  • Download the Apache Maven package from this link.
  • Ensure that the package is saved to your "/Applications" directory.
  • Open the terminal and enter the following command to install the package:
    $ sudo installer -pkg "/Applications/apache-maven-3.6.3-bin.tar.gz" -target /

On Linux:

  • Download the Apache Maven package from this link.
  • Ensure that the package is saved on a directory that you have access to.
  • Open the terminal and enter the following command to install the package:
    $ sudo tar zxvf “/path/to/apache-maven-3.6.3-bin.tar.gz” -C /opt

Step 4: Install NetBeans

The final step is to install NetBeans. This is an integrated development environment (IDE) used by many Java developers.

On MacOS:

  • Download the NetBeans package from this link.
  • Ensure that the package is saved to your "/Applications" directory.
  • Open the terminal and enter the following command to install the package:
    $ sudo installer -pkg "/Applications/NetBeans 8.1.dmg" -target /

On Linux:

  • Download the NetBeans package from this link.
  • Ensure that the package is saved on a directory that you have access to.
  • Open the terminal and enter the following command to install the package:
    $ sudo ./netbeans-8.1-linux-x64.sh

Conclusion

By following the steps outlined in this guide, you should now have the Java 11 OpenJDK development environment installed and ready to use on your local system. The final part is to start writing your Java projects with NetBeans and Apache Maven.

FAQ

Here are some answers to commonly asked questions about installing the Java 11 OpenJDK development environment:

Q: What is Java?

A: Java is an object-oriented programming language created by Sun Microsystems (which has since been acquired by Oracle). It’s used to develop applications for multiple platforms, including Windows, MacOS, and Linux.

Q: What is OpenJDK?

A: OpenJDK is an open source implementation of the Java platform. It’s freely available for download and use, allowing developers to access the latest version of Java to create their applications.

Q: What are the prerequisites for installing the OpenJDK development environment?

A: Before you begin, make sure you have the following installed and set up: a Linux or MacOS system, Apache Maven 3.2 or later, NetBeans IDE 8.1 or later, and JDK 1.8 or higher.

Q: How do I install OpenJDK 11?

A: On MacOS, download the AdoptOpenJDK package from this link and save it to the “/Applications” directory. Open the terminal and enter the “sudo installer -pkg” command to install the package. On Linux, download the package from this link and save it on a directory that you have access to. Run the “sudo yum install” command depending on your architecture.

Q: How do I set up the JAVA_HOME environment variable?

A: On MacOS, open the “.bash_profile” file in the terminal and enter the “export JAVA_HOME” command. On Linux, open the “bashrc” and enter the same command. Save the file and then enter the “source” command to let the changes take effect.

Q: What’s the last step of the installation process?

A: The last step is to install NetBeans. This is an integrated development environment (IDE) used by many Java developers. Download the NetBeans package from this link and follow the instructions in Step 4 of the guide.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Lxadm.com.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.