Java Development Setup Guide for Windows
This guide provides a comprehensive, step-by-step walkthrough to configure your Microsoft Windows environment for Java development.
Installation Checklist
- Download and Install Java JDK (LTS 17 or 21)
- Configure
JAVA_HOMESystem Variable - Add JDK Binaries to the System
PATH - Verify JDK Installation via command-line
- Install IDE (IntelliJ IDEA / VS Code)
- Install Git and verify version control
- Compile and run a "Hello World" test program
Step 1: Install Java JDK
- Visit the official Oracle Java Downloads page or Eclipse Temurin (Adoptium):
- Oracle JDK Downloads
- Adoptium Temurin Downloads
- Choose the Windows tab and download the x64 Installer (
.exe). - Double-click the downloaded file (e.g.,
jdk-21_windows-x64_bin.exe) to launch the setup wizard. - Follow the default wizard prompt and note the installation path. It usually defaults to:
Step 2: Configure Environment Variables
For Windows to locate the Java compiler (javac) and launcher (java), you must register their paths in your environment variables.
1. Create JAVA_HOME
- Press the
Winkey, type Environment Variables, and select Edit the system environment variables. - In the System Properties window, click the Environment Variables... button at the bottom.
- Under the System variables section (bottom half), click New....
- Set the following values:
- Variable name:
JAVA_HOME - Variable value:
C:\Program Files\Java\jdk-21(Ensure this matches your actual installation folder path!) - Click OK.
2. Update System PATH
- Still inside the System variables list, scroll down, locate the Path variable, and click Edit....
- In the Edit Environment Variable window, click New on the right side.
- Add the following entry:
- Click OK on all open windows to save the changes.
Step 3: Verify the Installation
To verify that Java is installed and registered correctly: 1. Open a new instance of Command Prompt (cmd) or PowerShell. 2. Execute the following verification commands:
Expected Output
If correctly set up, you should see output similar to this:
openjdk version "21.0.1" 2023-10-17 LTS
OpenJDK Runtime Environment Temurin-21.0.1+12 (build 21.0.1+12-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.1+12 (build 21.0.1+12-LTS, mixed mode, sharing)
javac 21.0.1
Step 4: Install Recommended IDEs
Install one of the following recommended code editors for Java development:
- IntelliJ IDEA (Recommended): Download the free Community Edition from JetBrains.
- Download IntelliJ IDEA
- Visual Studio Code: Ensure you install the "Extension Pack for Java" extension.
- Download VS Code
Step 5: Install Git Version Control
- Download the Windows installer from Git SCM Windows.
- Run the installer, select default settings, and finish installation.
- Open Command Prompt and verify:
Step 6: Write, Compile, and Run Your First Program
Let's test the environment manually from scratch:
- Open notepad or your code editor and save the following code as
HelloWorld.javain a local folder (e.g.,C:\JavaProjects\):
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Windows Java Development!");
}
}
-
Open Command Prompt and navigate to your project directory:
-
Compile the Java class:
-
Run the compiled bytecode program:
Output:
Common Issues and Troubleshooting
[!WARNING]
'javac' is not recognized as an internal or external command
- Cause: The
PATHenvironment variable does not point to your JDKbindirectory.- Fix: Re-verify Step 2. Make sure
%JAVA_HOME%\binis added to your Path, and that you opened a brand new Command Prompt since applying those changes.[!IMPORTANT]
Error: JAVA_HOME points to a JRE instead of a JDK
- Cause: You might have downloaded the Java Runtime Environment (JRE) instead of the Java Development Kit (JDK). JRE can run programs but lacks compile tools like
javac.- Fix: Uninstall JRE, download JDK from Adoptium or Oracle, and update your
JAVA_HOMEpath.
Back to Module Home: 01_SETUP README