What is the JVM?
Fast recall
Quick revision
Core answer
Interview-ready guide
Interview answer
The Java Virtual Machine, or JVM, is the runtime that executes Java class files. The JVM specification defines the common rules, while an implementation such as HotSpot provides those rules for a particular operating system and processor.
Java source is normally compiled by javac into .class files containing bytecode. At runtime, the JVM loads the required classes, checks the class-file structure, links references, initializes classes when needed, and executes their methods.
For example, the same Hello.class can run on an x64 Linux JVM and an ARM macOS JVM. Each JVM understands the same bytecode and turns it into work for its own machine. Native libraries can still be platform-specific.
The JVM also manages runtime memory, garbage collection, threads, exceptions, and access to native code. It may interpret bytecode or compile hot code to native instructions. The JVM is not the whole JDK: the JDK also contains development tools such as javac, jar, and javap.
What is the JVM
Direct Answer
The Java Virtual Machine is an abstract execution machine defined by a specification and implemented by runtimes such as HotSpot. It loads and verifies class files, executes bytecode, manages runtime memory and threads, and provides the platform boundary that lets the same valid class file run on different systems.
Deep Dive & Architecture
Why an abstract machine matters
The JVMS describes an instruction set, class-file format, runtime areas, and execution rules without prescribing one concrete object layout, garbage collector, JIT strategy, or memory-address arrangement. HotSpot, OpenJ9, and another compliant implementation can organise their internals differently while preserving the behaviour required by the specification.
From source code to JVM execution
When javac compiles System.out.println(2 + 3), it produces a class file for the JVM instruction set. A Linux x86-64 runtime and a macOS ARM runtime both understand that class-file contract. Each runtime loads and verifies the class, then interprets or compiles its methods into a form its own processor can execute. The shared class file is portable; the runtime's generated machine instructions are not.
The boundary of JVM portability
Code using Java's standard APIs can usually move between compatible runtimes, but JNI libraries, operating-system paths, external commands, file permissions, native fonts, timing assumptions, and vendor-specific flags can tie an application to one environment. The JVM creates a portable execution boundary; it does not make every dependency portable.
Managed does not mean automatic correctness
Bytecode verification checks structural and type-safety rules, and garbage collection manages unreachable heap storage. Neither proves that authorization rules are correct, prevents a data race, or chooses the right algorithm. The useful mental model is a well-defined execution contract plus runtime services, with application correctness still belonging to the program.
Code Example
class WhatIsTheJvm {
public static void main(String[] args) {
System.out.println(System.getProperty("java.vm.name"));
System.out.println(System.getProperty("java.vm.vendor"));
System.out.println(System.getProperty("java.vm.version"));
}
}
Check your understanding
Answer these without looking back at the article.
- What is the difference between the JVM specification and HotSpot?
- Is JIT compilation required by the JVM specification?
- What is the difference between the JVM and the JDK?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.