Video in progress

How do the JDK, JRE and JVM differ from each other?

The JVM is the virtual machine that executes bytecode. The JRE is the JVM plus the standard libraries, enough to run a program. The JDK is the JRE plus developer tools like javac, jar and jcmd.

📖 Answer

Put simply, they are boxes nested inside each other:

What Inside Who needs it
JVM interpreter, JIT, GC, class loader to execute bytecode
JRE JVM + java.base, java.sql and other modules to run a program
JDK JRE + javac, jar, javap, jcmd, jfr for writing code and diagnostics

Starting with Java 11, Oracle stopped shipping a separate JRE download. Today you normally install the JDK, and if you need a small runtime, you build an image with only the modules you need using jlink.

Practical advice: it is worth putting the JDK in your production Docker image too, so jcmd and jstack are at hand when there is a problem. If image size matters, there are JRE images like eclipse-temurin:21-jre, but then you don't have the diagnostic tools.