Guide
What is the JVM?
The Java Virtual Machine explained at three levels: what it is, what it does when a Java program runs, and how the specification differs from HotSpot, with verified examples and sources.
Java Virtual Machine
JVM specificationAn abstract machine defined by the JVM Specification; HotSpot is the implementation shown here.
Simply put
The JVM is the engine that runs Java bytecode. It loads classes, manages memory, runs code (first by interpreting it, then by compiling hot parts to machine code), and cleans up memory that is no longer used.
What a developer sees
You start a JVM with the java command. java -cp out app.Main creates a JVM inside a new operating-system process, loads Main and calls its main method. The program ends when every non-daemon thread has finished, or when something calls System.exit.
Everything your program uses while it runs lives inside that process: loaded classes, threads and their stacks, the heap, compiled code. jcmd <pid> VM.version, jconsole and JDK Flight Recorder attach to a running JVM to show what is inside.
Picture it
Think of a games console. A game made for that console plays on every one of them, whatever television it is plugged into.
- The game
Your class files (bytecode)
- The console
The JVM
- Different televisions and homes
Different operating systems and processors
Where the picture stops working
A console just plays a game as it is. The JVM also checks every class before running it, translates busy code into machine code for its own processor, and manages memory for the program. And it is not a separate box: the JVM is itself a program running on your computer.
Deep dive: the specification and HotSpot in detail
The JVM Specification defines the class file format, the instruction set, loading, linking and initialization, and the run-time data areas — abstractly. It deliberately leaves memory layout, garbage collection algorithms and compilation strategy to implementations (JVMS §2.13). HotSpot, the OpenJDK implementation used by most JDK distributions, is a C++ library (libjvm) with a template interpreter, the C1 and C2 JIT compilers and several garbage collectors. Other JVMs (Eclipse OpenJ9, for example) satisfy the same specification with different internals.
The specification requires
Defines behaviour: what each instruction does, when classes are initialized, which errors are thrown. Says nothing about object layout, GC algorithms or JIT compilers.
HotSpot (JDK 25) does
HotSpot (JDK 25) adds concrete structures you will see dashed in this atlas: Metaspace, the code cache, C1/C2, tiered profiling, G1 regions, TLABs and deoptimization.
Common misconceptions
JDK, JRE and JVM are interchangeable names.
The is the execution engine. A Java runtime () is the JVM plus the class library. The adds development tools such as
javac,javapandjcmd. OpenJDK has not shipped a separate JRE since JDK 11;jlinkbuilds custom runtimes instead.Everything in this diagram is required by the specification.
Only the solid-outlined parts are specification concepts. Dashed parts are HotSpot implementation choices that can change between releases.
Sources
- SpecJVMS §2.13 Public Design, Private Implementation(opens in a new tab)
Implementations may translate bytecode to native code and choose their own internals. · Java SE 25
- SpecJVMS §2.5 Run-Time Data Areas(opens in a new tab)
Defines the data areas used during program execution and which are per thread. · Java SE 25
- GuideJava Virtual Machine Guide(opens in a new tab)
HotSpot features including class data sharing, compilation and signal handling. · JDK 25
JDK, JRE and HotSpot
- JDK
The download developers install: a Java runtime plus tools such as
javac,javapandjcmd.JDK in the glossaryA JDK contains a full Java runtime (the JVM and the class library as a modular runtime image) and development tools: the compiler (
javac), disassembler (javap), diagnostics (jcmd,jfr), packaging (jar,jlink,jpackage) and more. Distributions (Oracle JDK, Eclipse Temurin, Amazon Corretto, Ubuntu's OpenJDK…) are mostly built from the same OpenJDK sources.- JRE
A Java runtime without the developer tools: enough to run Java programs, not to build them.
JRE in the glossaryHistorically a separate download containing the JVM and the class library. OpenJDK stopped producing a standalone JRE with JDK 11; today runtimes are either a full JDK or a custom, smaller runtime image built with
jlinkcontaining only the modules an application needs.- HotSpot
The JVM that ships with OpenJDK and most Java downloads. Its name comes from finding the "hot spots" of a program and compiling them.
HotSpot in the glossaryOpenJDK's JVM implementation, written mostly in C++ (
libjvm). It provides a template interpreter, the C1 and C2 JIT compilers with tiered compilation, several garbage collectors (Serial, Parallel, G1, ZGC, Shenandoah, Epsilon), Metaspace, class data sharing and extensive diagnostics. Everything dashed in this atlas is a HotSpot (JDK 25) structure.