Java Architecture — JDK, JRE & JVM Explained

This page explains the three core components that make Java platform-independent and powerful: JDK, JRE, and the JVM. Save this as a quick reference for interviews and exams.

Overview

Java’s architecture is designed around the idea of portability and security. The three pillars:

Together they enable the famous motto: Write Once, Run Anywhere (WORA).

JDK — Java Development Kit

The JDK is the full kit for developing Java applications. If you plan to write and compile Java code, you need the JDK.

What JDK contains: the Java compiler (javac), the JRE, debugging tools, and utilities like jar, javadoc, etc.

// Write source // Hello.java public class Hello { public static void main(String[] args) { System.out.println("Hello, Java Architecture!"); } } // Compile (using JDK) // javac Hello.java // Produce Hello.class (bytecode)

Developers use the JDK to compile source code into bytecode (.class files) which the JVM later executes.

JRE — Java Runtime Environment

The JRE provides the runtime libraries and the JVM — everything required to run Java applications.

JRE includes: the JVM implementation, core class libraries (rt.jar or modules), and configuration files for runtime.

End users who only need to run Java programs (not develop) typically install the JRE or use a JVM bundled with the OS or container image.

JVM — Java Virtual Machine

The JVM is the heart of Java. It reads bytecode (.class files), verifies them for safety, and executes them on the host machine.

Key responsibilities of the JVM:

// Conceptual bytecode (illustrative) // 0x2A: aload_0 // 0xB6: invokevirtual #3 // (JVM interprets/compiles these into machine instructions)

The JVM abstracts away OS and hardware differences — so the same bytecode runs across platforms.

Execution Flow: Source → Bytecode → Native Code

Step-by-step how Java runs your program:

  1. Write Java source file: Hello.java
  2. Compile with javac (JDK) → produces Hello.class (bytecode)
  3. Load the class: JVM ClassLoader loads Hello.class
  4. Verify bytecode for security and correctness
  5. Execute: JVM interprets or uses the JIT compiler to produce optimized native code
  6. Run on the host OS — same bytecode, different machines

Note: The JIT compiler compiles "hot" methods to native code at runtime, dramatically improving performance compared to pure interpretation.

Summary & Why It Matters