Card 04/ 06

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.

What each of the three is, and what it contains
NameWhat it isContainsYou need it to
JVM — Java Virtual MachineThe engine that executes bytecodeNothing else; it is the innermost pieceRun bytecode, and nothing more
JRE — Java Runtime EnvironmentThe JVM plus the standard libraryThe JVM, plus String, List, files, networkingRun a program somebody else compiled
JDK — Java Development KitThe JRE plus the tools that make bytecodeThe JRE, plus javac, jar, jshell, a debuggerCompile 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 JDK contains the JRE, which contains the JVM

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.