Updated: July 23, 2025

Java Development Kit (JDK) is an essential toolkit for developers who want to create Java applications. It contains the Java Runtime Environment (JRE), an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), and other tools needed for Java development. Installing the JDK correctly is the first step toward building and running Java applications on your computer.

This article provides a comprehensive, step-by-step guide to installing the latest version of the Java JDK on both Windows and Mac operating systems.

What is Java JDK?

Before diving into the installation process, it’s important to understand what the JDK is and why it matters.

  • Java Development Kit (JDK): A software development environment used for developing Java applications and applets.
  • Includes: Java Runtime Environment (JRE), development tools like the compiler (javac), debugger, and other utilities.
  • Purpose: To enable developers to write, compile, run, debug, and document Java applications.

Prerequisites

  • A stable internet connection to download the JDK installer.
  • Administrative privileges on your computer to install software.
  • Familiarity with basic command line usage (optional but helpful).

How to Install Java JDK on Windows

Step 1: Download the JDK Installer

  1. Open your preferred web browser.
  2. Visit the official Oracle JDK download page: https://www.oracle.com/java/technologies/downloads/
  3. Locate the latest version of Java SE Development Kit.
  4. Choose the Windows installer , options are typically available as .exe or .zip. The .exe installer is recommended for ease of installation.
  5. Click on the download link and accept the license agreement if prompted.

Step 2: Run the Installer

  1. Once downloaded, navigate to your Downloads folder.
  2. Double-click on the .exe file to launch the installer.
  3. If prompted by User Account Control, click Yes to allow changes.

Step 3: Follow Installation Wizard

  1. In the setup wizard window, click Next.
  2. Choose your installation folder or leave it as default (C:\Program Files\Java\jdk-version).
  3. Click Next again to begin installation.
  4. Wait for the installation process to complete.
  5. Click Close once done.

Step 4: Set Environment Variables

To use Java from any command prompt window, you need to set environment variables (JAVA_HOME and update PATH).

Set JAVA_HOME Variable

  1. Open Start Menu, search for Environment Variables, and select Edit the system environment variables.
  2. In the System Properties window, click Environment Variables.
  3. Under System variables, click New.
  4. Enter JAVA_HOME as Variable name.
  5. For Variable value, enter your JDK installation path, e.g., C:\Program Files\Java\jdk-version.
  6. Click OK.

Update PATH Variable

  1. In Environment Variables window under System variables, find and select Path.
  2. Click Edit.
  3. Click New, then add %JAVA_HOME%\bin.
  4. Click OK in all windows to apply changes.

Step 5: Verify Installation

  1. Open Command Prompt (cmd.exe).
  2. Type java -version and press Enter , this shows the installed JRE version.
  3. Type javac -version and press Enter , this shows installed compiler version.

If both commands return version information without errors, you have successfully installed Java JDK on Windows.


How to Install Java JDK on Mac

Step 1: Download the JDK Installer for Mac

  1. Open Safari or any browser.
  2. Visit Oracle’s official download page: https://www.oracle.com/java/technologies/downloads/
  3. Find the latest macOS version of Java SE Development Kit.
  4. Download either .dmg or .pkg installer , .dmg is common on macOS.

Step 2: Install Using Installer Package

  1. Once downloaded, open Finder and go to your Downloads folder.
  2. Double-click the .dmg file to mount it.
  3. A new window will appear with an installer package (jdk-version.pkg).
  4. Double-click this file to start installation.
  5. Follow on-screen instructions:
  6. Click Continue
  7. Agree to software license terms
  8. Select target disk
  9. Click Install
  10. Enter your Mac administrator password when prompted.
  11. Wait for installation to complete, then click Close.

Step 3: Verify Installation via Terminal

  1. Open Terminal app (you can find it via Spotlight or in Applications > Utilities).
  2. Type java -version and press Enter , this shows installed runtime version.
  3. Type javac -version and press Enter , this shows installed compiler version.

If both commands display versions without errors, installation is successful.

Step 4: Set JAVA_HOME Environment Variable (Optional)

Most macOS setups automatically configure JAVA_HOME, but if you need to set or confirm it:

  1. Open Terminal.
  2. To find out where JDK is installed, type:

bash
/usr/libexec/java_home

  1. This command outputs the path of your current JDK installation, e.g., /Library/Java/JavaVirtualMachines/jdk-version.jdk/Contents/Home.

  2. To set JAVA_HOME temporarily in Terminal session:

bash
export JAVA_HOME=$(/usr/libexec/java_home)

  1. To make this change permanent:

  2. Open or create your shell configuration file (~/.zshrc for zsh or ~/.bash_profile for bash):

    bash
    nano ~/.zshrc

  3. Add this line at the end:

    bash
    export JAVA_HOME=$(/usr/libexec/java_home)

  4. Save file (Ctrl + O, then Enter) and exit (Ctrl + X).

  5. Run source ~/.zshrc to reload configuration.

Troubleshooting Common Issues

Even with straightforward instructions, users might face some common issues during installation:

Issue: ‘java’ or ‘javac’ Not Recognized

  • On Windows, double-check that %JAVA_HOME%\bin is correctly added to PATH environment variable.
  • Restart Command Prompt or reboot computer after setting environment variables.

Issue: Incorrect Version Shown

  • Check if multiple versions of JDK are installed; remove older versions if necessary.
  • Use full path commands like "C:\Program Files\Java\jdk-version\bin\java" -version.

Issue: Permission Denied During Installation

  • Make sure you have administrator rights when installing software on both Windows and macOS.
  • On macOS, try running Terminal commands with sudo, but avoid using sudo for regular usage.

Additional Tips for Java Developers

  • Always install the latest Long-Term Support (LTS) version unless you explicitly need a specific earlier release.
  • Regularly update your JDK installation to benefit from security patches and performance improvements.
  • Consider using OpenJDK distributions like AdoptOpenJDK or Amazon Corretto if Oracle licensing terms do not fit your needs.
  • Use Integrated Development Environments (IDEs) like Eclipse, IntelliJ IDEA, or NetBeans that detect installed JDKs automatically for smoother development workflows.

Conclusion

Installing Java JDK on Windows and Mac computers is straightforward when following official steps carefully:

  • Download from Oracle’s website or trusted OpenJDK sources.
  • Run installers appropriate for your OS (.exe for Windows; .dmg/.pkg for Mac).
  • Set environment variables like JAVA_HOME and update PATH so that you can use java commands globally in terminal or command prompt.
  • Verify installation by checking versions with java -version and javac -version.

With these steps completed successfully, you are now ready to start developing and running Java applications on your machine!