Learn · concepts

What is the JVM? Java Virtual Machine Explained

The JVM runs Java bytecode on any operating system. It is why Minecraft Java Edition and every Fabric mod run the same on Windows, macOS, and Linux.

TRtrolPublished 4 min read

What is the JVM?

The JVM, or Java Virtual Machine, is the program that runs Java code. You write Java, a compiler turns it into bytecode, and the JVM runs that bytecode on any operating system. This is why Minecraft Java Edition and the mods built for it behave the same on Windows, macOS, and Linux without recompiling. The JVM is the abstraction layer that makes "write once, run anywhere" a real thing instead of a marketing slogan.

What the JVM actually does

The JVM runs bytecode, not source code. When you compile a Java program you do not get a Windows or Mac executable. You get class files full of bytecode, a compact instruction set the JVM understands. The JVM reads those instructions and executes them on your machine.

That extra layer is the point. The same bytecode runs anywhere a JVM exists, so "write once, run anywhere" is the short version of why Java spread so widely. The JVM is the part that makes the promise true. A jar file of Fabric mods works the same whether the player is on Windows, macOS, or Linux, because they're all running the same bytecode through the same JVM, and the JVM handles the hardware differences.

JVM, JRE, and JDK

These three terms get mixed up a lot, so here is the split.

TermWhat it isWhen you need it
JVMThe engine that runs bytecodeAlways, to run any Java program
JREThe JVM plus the standard librariesTo run Java programs
JDKThe JRE plus the compiler and dev toolsTo build Java programs

A player only needs a runtime to launch the game. A developer building a mod needs the full JDK so they can compile Java into bytecode in the first place.

How the JVM runs your code fast

The JVM starts by interpreting bytecode one instruction at a time. As it runs, it watches which methods get called the most. Those hot paths get handed to the JIT compiler, which turns them into native machine code on the fly. After warm-up, the busiest code runs at close to native speed. That's why Minecraft feels laggy for the first few seconds and then settles in: the JIT is working in the background.

The JVM also manages memory for you. A garbage collector reclaims objects you stop using, so you do not free memory by hand the way you would in C. This is one reason Java is forgiving to write and a common first language for modders. Memory management is built in.

Why it matters for Minecraft

Minecraft Java Edition runs on the JVM, and so does every utility client and mod that targets it. A client's own code can be Java, Kotlin, or another JVM language, because they all compile to the same bytecode the JVM runs. A Fabric mod ships as a jar of bytecode, the loader wires it into the game at launch, and the JVM runs the whole thing as one process.

This is also why launchers let you tune things like the heap size and which Java version to use. You are configuring the JVM that hosts the game, not the game itself. Giving the JVM more memory means Minecraft has more space to work with. Choosing a newer Java version might give you speed improvements, since newer JVMs often optimize hot code paths better.

FAQ