Skip to main content

2.1 JDK vs JRE vs JVM Architecture

← Back to Chapter 2: Java Overview & Memory Model

Java’s platform independence relies on a tiered abstraction model separating the compiler, the runtime libraries, and the underlying execution virtual machine.


1. Architectural Relationship​

┌─────────────────────────────────────────────────────────────┐
│ JDK (Java Development Kit) │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ JRE (Java Runtime Environment) │ │
│ │ ┌──────────────────────┐ ┌───────────────────────────┐ │ │
│ │ │ JVM │ │ Standard Libraries │ │ │
│ │ │ (Java Virtual Machine)│ │ (rt.jar, java.base, etc.) │ │ │
│ │ └──────────────────────┘ └───────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────┘ │
│ Development Tools (javac, javadoc, jar, jdb, jstat, jcmd) │
└─────────────────────────────────────────────────────────────┘

Breakdown:​

  1. JVM (Java Virtual Machine):
    • Abstract computing machine that executes compiled .class bytecode.
    • Platform-dependent: JVM implementations exist for Windows (x64/ARM), Linux, macOS, etc.
    • Responsible for class loading, memory management, garbage collection, and thread orchestration.
  2. JRE (Java Runtime Environment):
    • Contains the JVM plus Java core class libraries (java.lang, java.util, java.io, etc.).
    • Provides everything needed to run compiled Java applications, but cannot compile source code.
    • (Note: Starting from Java 11, standalone JRE bundles were phased out in favor of modular runtime images via jlink).
  3. JDK (Java Development Kit):
    • Complete superset for software engineers.
    • Includes JRE + JVM + Developer CLI tools:
      • javac (Java compiler)
      • jar (Archive packager)
      • javap (Bytecode disassembler)
      • jcmd / jstack / jmap (JVM diagnostics and profiling tools)

2. "Write Once, Run Anywhere" (WORA)​

Java source code (.java) is compiled into an intermediate representation called Bytecode (.class), rather than native machine assembly code (x86/ARM). Any operating system with a compatible JVM can interpret and execute that same .class file seamlessly without recompilation.