Steps to install the Java Development Kit (JDK) on Windows, macOS, and Linux.

1. Choose JDK Version and Vendor
Popular JDK vendors:
-
Oracle JDK – official version
-
OpenJDK – open-source
-
Amazon Corretto, Azul Zulu, Adoptium – alternative builds
For most purposes, Adoptium Temurin or Oracle JDK is recommended.
Windows Installation
Option 1: Using Oracle JDK
-
Go to: https://www.oracle.com/java/technologies/javase-downloads.html
-
Select the version (e.g., Java 17 or Java 21 LTS).
-
Download the .exe installer.
-
Run the installer and follow the prompts.
-
Verify installation:
Open Command Prompt and run:java -version javac -version
Option 2: Using Adoptium (OpenJDK)
-
Go to: https://adoptium.net/
-
Choose a version (e.g., Java 17) and Windows OS.
-
Download the MSI Installer.
-
Install and follow prompts.
-
Confirm with:
java -version
macOS Installation
Option 1: Oracle JDK
-
Go to https://www.oracle.com/java/technologies/javase-downloads.html
-
Download the macOS .dmg installer.
-
Open and run the installer.
-
To verify:
java -version
Option 2: Using Homebrew (Recommended for developers)
-
Open Terminal.
-
Run:
brew install openjdk@17
-
Add Java to your PATH:
echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zprofile source ~/.zprofile
-
Verify:
java -version
Linux Installation (Ubuntu/Debian)
Option 1: Default JDK from Repository
sudo apt update
sudo apt install default-jdk -y
Option 2: Install Specific Version (e.g., OpenJDK 17)
sudo apt install openjdk-17-jdk -y
Verify Installation:
java -version
javac -version
After Installation
-
Set JAVA_HOME (Optional but useful):
-
On Windows: Set Environment Variable
JAVA_HOME
to the JDK path (e.g.,C:\Program Files\Java\jdk-17
) -
On Linux/macOS:
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java)))) export PATH=$JAVA_HOME/bin:$PATH
-
-
IDE Integration: Install an IDE like IntelliJ IDEA, Eclipse, or VS Code with Java extensions.