Java Environment Setup: Installing JDK 21 LTS, Configuring PATH & IDEs

To begin coding in Java, you need two fundamental tools on your computer: the Java Development Kit (JDK) to compile and run your source code, and a reliable Integrated Development Environment (IDE) or text editor to write your programs.

Step 1: Downloading & Installing JDK 21+ LTS

We recommend installing Eclipse Temurin 21 (Adoptium) or Oracle OpenJDK 21. Follow these instructions for your platform:

Windows Installation:

  1. Visit adoptium.net and download the JDK 21 (LTS) Windows x64 .msi installer.
  2. Run the installer. During the feature selection step, ensure you enable "Set JAVA_HOME variable" and "Add to PATH".
  3. Click Install and finish the wizard.

Step 2: Configuring JAVA_HOME & PATH Manually (Windows)

If the installer did not configure environment variables automatically, follow these manual steps:

  1. Press Win + R, type sysdm.cpl, and press Enter to open System Properties.
  2. Switch to the Advanced tab and click Environment Variables.
  3. Under System variables, click New:
    • Variable name: JAVA_HOME
    • Variable value: C:Program FilesEclipse Adoptiumjdk-21.0.x-hotspot (the folder path where JDK is installed).
  4. Select the Path variable under System variables and click Edit.
  5. Click New and add: %JAVA_HOME%in. Click OK on all windows.

Step 3: Verifying Java Installation in Terminal

Open a new Command Prompt (cmd) or PowerShell window and execute the following commands:

# Check Java Runtime version
java -version

# Output should resemble:
# openjdk version "21.0.2" 2024-01-16
# OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13)
# OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13, mixed mode, sharing)

# Check Java Compiler version
javac -version
# Output: javac 21.0.2

Step 4: Compiling and Running via Command Line

Every developer should master manual terminal compilation before using an IDE:

# 1. Create a file named TestApp.java
# 2. Compile source code into bytecode (.class)
javac TestApp.java

# 3. Launch the bytecode on the JVM (omit the .class extension!)
java TestApp

University Practical Lab Corner

Common Viva Question: "What error happens if you execute java TestApp.class instead of java TestApp?"

Answer: The JVM throws Error: Could not find or load main class TestApp.class. The java command expects the fully-qualified class name, not the physical filesystem filename!

Next Step

With JDK 21 installed, let us analyze the tripartite relationship between JVM, JRE, and JDK. Proceed to: JVM vs JRE vs JDK Architecture →

Frequently Asked Questions (FAQ)

Q1. Which JDK distribution should I install in 2026?
For production and student learning, recommended free open-source distributions include Eclipse Temurin (Adoptium), Amazon Corretto, Azul Zulu, or Oracle OpenJDK. They are completely free for commercial and academic use.
Q2. Why do I need to configure the JAVA_HOME environment variable?
JAVA_HOME points to the root directory where the JDK is installed. Build automation tools (Maven, Gradle), application servers (Tomcat), and developer IDEs rely on JAVA_HOME to locate the Java compiler and runtime executables.
Q3. What is the best IDE for Java programming?
IntelliJ IDEA (Community or Ultimate) is the industry gold standard due to its unmatched code completion, debugging, and refactoring capabilities. Visual Studio Code (with Extension Pack for Java) and Eclipse IDE are also widely used.

Explore Related Java Tutorials

Accelerate your Java mastery by studying these tightly connected core tutorials:

Java Home & Roadmap →

Tutorial curriculum.

JVM vs JRE vs JDK →

Internal components breakdown.

Java Program Structure →

Write and compile your first class.

Command Line Arguments →

Running classes from terminal.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!