Card 04/ 06
All 6 cards
ComparisonDifficulty: Intermediate1 min
JDK, JRE and JVM: Which One You Actually Install
Three acronyms turn up in every installation guide, in the same sentence, as though the difference were obvious. It is not, and picking the wrong one leaves you with a machine that can run Java and cannot compile it.
| Name | What it is | Contains | You need it to |
|---|---|---|---|
| JVM — Java Virtual Machine | The engine that executes bytecode | Nothing else; it is the innermost piece | Run bytecode, and nothing more |
| JRE — Java Runtime Environment | The JVM plus the standard library | The JVM, plus String, List, files, networking | Run a program somebody else compiled |
| JDK — Java Development Kit | The JRE plus the tools that make bytecode | The JRE, plus javac, jar, jshell, a debugger | Compile anything at all |
They nest. Every JDK contains a JRE, and every JRE contains a JVM. Nothing contains a JDK, which is why installing the smallest one leaves you stuck.
The decision rule. On any machine where you write code, install the JDK. On a machine that only runs a jar somebody else built — a container image, a server — a JRE is enough and is smaller. If you are unsure which of the two a machine is, it is a development machine and it wants the JDK.