JVM (Java Virtual Machine)
The Java Virtual Machine (JVM) is the runtime program that executes compiled Java bytecode. It translates platform-independent .class files into native machine instructions, manages memory via the garbage collector, and provides the security sandbox that Java programs run inside.
What the JVM does
- Loads classes on demand via the ClassLoader hierarchy.
- Verifies bytecode before execution to reject malformed or unsafe class files.
- Interprets then JIT-compiles hot code paths into optimised native instructions.
- Manages memory automatically — allocation on the heap, collection by the garbage collector.
- Schedules threads, coordinating with the OS and (since Java 21) virtual threads on top.
JVM vs JDK vs JRE
The JVM is the runtime engine. The JRE (Java Runtime Environment) = JVM + standard class library. The JDK (Java Development Kit) = JRE + compiler and developer tools. See JDK vs JRE vs OpenJDK for the full breakdown.
HotSpot, OpenJ9, GraalVM
There are several JVM implementations. HotSpot (Oracle / OpenJDK) is by far the most widely used. OpenJ9 (Eclipse Foundation) is optimised for low memory footprint. GraalVM is a polyglot JVM that also supports ahead-of-time native image compilation.
Running the JVM
java -version # print JVM version
java -jar app.jar # run a JAR file
java -Xmx4G -jar app.jar # set max heap to 4 GB
java -XX:+PrintFlagsFinal -version | head -30 # list JVM flags