Course contentsShow
Java
Lesson 2 of 2,8701. Java Setup and First ProgramFree lesson

JDK vs JRE vs JVM: The Three-Layer Architecture

Distinguishing between the Java Development Kit, Java Runtime Environment, and Java Virtual Machine and their roles.

JDK vs JRE vs JVM: The Three-Layer Architecture

What you'll learn: How the JDK, JRE, and JVM work together in a three-layer system to run your Java programs.

The Three Layers Explained

Think of building and running a Java program like preparing and eating a meal:

JVM (Java Virtual Machine) — The Bottom Layer
This is your stomach. It's the engine that actually digests (runs) Java programs. The JVM reads compiled Java code (called bytecode) and executes it on your computer. Every computer needs a JVM to run Java programs, but you never interact with it directly.

JRE (Java Runtime Environment) — The Middle Layer
This is your kitchen with basic appliances. It contains the JVM plus a library of pre-written Java code (like tools for working with text, numbers, and files). If you only want to run Java programs that someone else wrote, the JRE is enough. It includes everything needed to execute Java applications.

JDK (Java Development Kit) — The Top Layer
This is your fully-stocked professional kitchen with chef's tools. It contains the JRE (which contains the JVM) plus development tools like the compiler (javac) that turns your human-readable code into bytecode. You need the JDK to write and build Java programs.

The Relationship

┌─────────────────────────────┐
│  JDK (Development Tools)    │  ← You write code here
├─────────────────────────────┤
│  JRE (Libraries + JVM)      │  ← Programs run here
├─────────────────────────────┤
│  JVM (Execution Engine)     │  ← Code executes here
└─────────────────────────────┘

When you installed the JDK earlier, you actually got all three layers! The JDK includes everything you need as a developer.

Key Takeaway: The JVM runs your code, the JRE provides the JVM plus libraries to run programs, and the JDK provides everything in the JRE plus tools to create programs. As a beginner developer, you installed the JDK, which gave you the complete package.