Three nested boxes: the JDK (tools to build) contains the JRE (what's needed to run) which contains the JVM (the engine that executes bytecode).
JDK = JRE + development tools (javac, jar, javadoc, jdb, jshell…)
JRE = JVM + class libraries (java.lang, java.util, …)
What each one is
| JDK | JRE | JVM | |
|---|---|---|---|
| Purpose | Develop + run | Run | Execute bytecode |
Contains javac? | Yes | No | No |
| Contains class library? | Yes | Yes | No |
| Platform dependent? | Yes | Yes | Yes |
Inside the JVM
Class loader subsystem
Finds
.classfiles, loads them, links (verify → prepare → resolve) and initialises them.Runtime data areas
Heap (objects), Method Area / Metaspace (class metadata), one Stack per thread (frames with local variables), PC registers, native method stacks.
Execution engine
Interpreter + JIT compiler (C1 quick, C2 optimising) + Garbage Collector.
JNI / native libraries
Bridge to C/C++ code (
nativemethods).
Checking what you have
public class Main {
public static void main(String[] args) {
System.out.println("feature version: " + Runtime.version().feature());
System.out.println("spec version: " + System.getProperty("java.specification.version"));
System.out.println("class file ok: " + (Main.class.getName().equals("Main")));
}
}feature version: 21
spec version: 21
class file ok: true$ java -version # runtime version
$ javac -version # compiler version (only in a JDK)
$ echo $JAVA_HOME # where the JDK is installedOpenJDK distributions
All major builds come from the same OpenJDK source; they differ in licensing, support length and extras.
Eclipse Temurin · Amazon Corretto · Oracle JDK / Oracle OpenJDK · Azul Zulu · Microsoft Build of OpenJDK · GraalVM
What is the difference between JDK, JRE and JVM?
Is the JVM platform independent?
What is the JIT compiler?