JDK vs JRE vs JVM: The Difference Explained (Beginner Guide)
JDK vs JRE vs JVM explained clearly with a diagram: what each one is, how they nest inside each other, which to install, and the memory trick to never confuse them again.
JDK, JRE, JVM — three acronyms that confuse every Java beginner, and a guaranteed interview question. The good news: once you see how they nest inside each other, it clicks permanently. This short guide explains each one in plain English, with a diagram, so you'll never mix them up again.
The one-line answers
- JVM (Java Virtual Machine) — runs your compiled Java code (bytecode).
- JRE (Java Runtime Environment) — everything needed to run Java apps (JVM + libraries).
- JDK (Java Development Kit) — everything needed to develop Java apps (JRE + tools like the compiler).
The key insight: they nest. JDK contains the JRE, which contains the JVM. Each layer adds more.
The JVM — the engine
The Java Virtual Machine is the program that actually executes your code. When you compile Java, you get platform-independent bytecode; the JVM reads that bytecode and runs it on your specific operating system. Because each OS has its own JVM, the same bytecode runs everywhere — that's Java's famous "write once, run anywhere." (More in the JVM & memory lesson.)
The JRE — the runtime
The Java Runtime Environment is the JVM plus the standard libraries your programs rely on (like java.util, java.io). If you only want to run Java applications (not write them), the JRE is all you need. It has everything to execute a program, but no development tools.
The JDK — the developer kit
The Java Development Kit is the full package for building Java software: it includes the entire JRE, plus development tools — most importantly the compiler (javac) that turns your .java source into bytecode, plus a debugger and other utilities. As a developer, you install the JDK.
Quick reference
| Contains | Use it to… | |
|---|---|---|
| JVM | the execution engine | execute bytecode |
| JRE | JVM + libraries | run Java apps |
| JDK | JRE + compiler + tools | develop Java apps |
This trio confused me for an embarrassingly long time when I started, until the nesting diagram above made it stick: JVM inside JRE inside JDK, each layer adding more. The memory trick that worked for me: VM = eValuate/execute, RE = Run, DK = Develop. As a developer you install the outermost one (JDK) and get all three. It's a small piece of knowledge, but interviewers ask it precisely because it reveals whether you understand how Java actually works under the hood — so nail it, and move on with confidence.