Overview
The Java Development Kit (JDK) is the core software development environment required to build Java applications, applets, and microservices. It includes:
- The Java Compiler (
javac): Compiles high-level Java source files (.java) into bytecode (.class). - The Java Runtime Environment (JRE /
java): Provides the Java Virtual Machine (JVM) and runtime libraries to execute compiled bytecode. - Development Utilities: Archiving tools (
jar), diagnostic debuggers (jdb), and profiling utilities.
For general software engineering, OpenJDK distributions (such as Eclipse Temurin by Adoptium, Amazon Corretto, or Microsoft Build of OpenJDK) are free, open-source, and unrestricted for commercial use.
Step 1: Downloading Eclipse Temurin (OpenJDK LTS)
- Navigate to the official Adoptium portal: adoptium.net.
- Select the latest LTS Release (e.g., Java 21 LTS or Java 17 LTS).
- Download the 64-bit Windows Installer (
.msi).
Alternatively, using Windows Package Manager (winget):
winget install EclipseAdoptium.Temurin.21.JDK
Step 2: Running the Installer and Configuring Features
When running the .msi wizard, inspect the Custom Setup options:
- Ensure Set JAVA_HOME variable is selected and set to “Will be installed on local hard drive”.
- Ensure Add to PATH is checked.
- Finish the installation.
Step 3: Setting JAVA_HOME Manually (If Required)
If you installed the JDK from an unzipped archive or need to manually configure the environment variable:
- Press
Win + S, typeEnvironment Variables, and choose Edit the system environment variables. - Click the Environment Variables… button at the bottom right.
- Under System Variables, click New…:
- Variable name:
JAVA_HOME - Variable value:
C:\Program Files\Eclipse Adoptium\jdk-21.0.x-hotspot\(Enter the directory wherebin\javac.exeresides).
- Variable name:
- Locate the
Pathvariable under System Variables, select it, and click Edit…. - Click New and add:
%JAVA_HOME%\bin - Click OK on all dialog boxes to persist the configuration.
Step 4: Verification of Java and Compiler
Open a brand new command prompt or PowerShell window (to load updated environment variables) and verify:
java -version
javac -version
Expected output:
openjdk version "21.0.5" 2024-10-15 LTS
OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.5+11 (build 21.0.5+11-LTS, mixed mode, sharing)
javac 21.0.5
Verify the JAVA_HOME path in PowerShell:
$env:JAVA_HOME
Step 5: Compiling and Running a Test Program
Create a quick test file to confirm proper compilation:
New-Item -Name "Hello.java" -Value 'public class Hello { public static void main(String[] args) { System.out.println("Java Environment Configured Successfully"); } }'
Compile and run:
javac Hello.java
java Hello
Output:
Java Environment Configured Successfully