Skip to content
UNASPACE

The Java Development Kit (JDK) provides the tools needed to develop Java applications. This guide covers installation on different operating systems.

There are several JDK distributions available:

  • Oracle JDK: Official Oracle implementation (requires license for commercial use)
  • OpenJDK: Free, open-source implementation
  • AdoptOpenJDK/Eclipse Temurin: Community-maintained, production-ready OpenJDK builds

For beginners, Eclipse Temurin (formerly AdoptOpenJDK) is recommended due to its ease of installation and long-term support.

  1. Download the JDK installer from Eclipse Temurin
  2. Run the installer and follow the installation wizard
  3. The installer will set the JAVA_HOME environment variable automatically
  4. Verify installation by opening Command Prompt and typing:
    java -version

Manual environment variable setup (if needed)

Section titled “Manual environment variable setup (if needed)”
  1. Right-click on “This PC” or “My Computer” and select “Properties”
  2. Click on “Advanced system settings”
  3. Click the “Environment Variables” button
  4. Under System Variables, click “New” and add:
    • Variable name: JAVA_HOME
    • Variable value: Your JDK installation path (e.g., C:\Program Files\Java\jdk-17)
  5. Edit the “Path” variable and add %JAVA_HOME%\bin
  1. Install Homebrew if not already installed:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  2. Install OpenJDK:
    brew install --cask temurin
  3. Verify installation:
    java -version
  1. Download the macOS .pkg file from Eclipse Temurin
  2. Open the downloaded file and follow the installation instructions
  3. Verify installation by opening Terminal and typing:
    java -version
Terminal window
sudo apt update
sudo apt install openjdk-17-jdk
Terminal window
sudo dnf install java-17-openjdk-devel
Terminal window
java -version

If you need multiple Java versions, consider using a version manager:

With SDKMAN, you can install and switch between Java versions:

Terminal window
sdk install java 17.0.2-tem
sdk use java 17.0.2-tem

Create a simple Hello World program to test your installation:

  1. Create a file named HelloWorld.java with the following content:
    public class HelloWorld {
    public static void main(String[] args) {
    System.out.println("Hello, Java!");
    }
    }
  2. Compile the program:
    javac HelloWorld.java
  3. Run the program:
    java HelloWorld

If you see “Hello, Java!” printed in the console, your Java installation is working correctly.

Built with passion by Ngineer Lab