Skip to content
IT glossary
BackendUpdated December 3, 2026

JVM

The Java Virtual Machine (JVM) runs compiled instructions called bytecode. The same bytecode can run on different operating systems and processors as long as each has a compatible JVM.

Also known as: Java Virtual Machine

What the JVM does

A Java compiler normally produces .class files rather than instructions for a particular CPU. These files contain bytecode: instructions defined by the JVM specification. A JVM implementation such as HotSpot executes them on the host. The JVM runs inside an operating-system process; it does not boot a guest OS like a machine-level virtual machine. Java isn't the only language it can run: Kotlin also has a compiler target that produces JVM bytecode.

From class file to running code

When a class is needed, a class loader locates it and brings it into the JVM. The JVM verifies the bytecode, checking constraints such as whether instructions receive operands of the expected types. Before the class's first active use, such as creating an instance, the JVM initializes it if necessary, running its static initializers. HotSpot can interpret bytecode and use a just-in-time (JIT) compiler to turn frequently executed code into native machine instructions. As the runtime gathers information about which paths the program takes, it can optimize those paths. That's one reason a service may behave differently just after startup than it does under steady load.

A quick example

Given a Hello.java file with a Hello class and a public static void main(String[] args) method:

javac Hello.java  # produce Hello.class
java Hello       # start the JVM and call Hello.main

javac is a development tool supplied by the JDK. The java launcher starts the JVM, and the runtime also supplies the standard libraries the program may use. Portability has limits: a class file built for a newer Java release won't run on a JVM that doesn't support its class-file version, and dependencies that call native code need compatible platform binaries.

Why backend engineers care

Threads have their own stacks for method calls, while objects are generally allocated in a shared heap. The garbage collector can reclaim objects that are no longer reachable. It won't reclaim records that an unbounded cache still strongly references, even if the application will never read them again.

Heap size is only one part of a service's memory budget. For example, setting -Xmx to 512 MB caps the Java heap, not the process's total memory usage. Thread stacks, class metadata, and JIT-compiled code also consume memory. A container can hit its memory limit even when the Java heap still has room.

In interviews

Expect to explain which steps happen at build time and which happen at runtime. For a question about rising memory usage, start by distinguishing the Java heap from total process memory. You'd investigate a heap that retains more objects after each collection differently from a process whose memory grows while the heap stays flat.