JVM (Java Virtual Machine)
The JVM is the engine that runs Java programs. It reads the compiled bytecode and executes it on your specific operating system, which is what lets the same Java program run on Windows, macOS, and Linux without changes.
Java
When you compile Java, you don't get machine code for one platform — you get platform-independent bytecode. The JVM translates that bytecode into instructions your computer understands, often using a Just-In-Time (JIT) compiler for speed.
The JVM also manages memory automatically through garbage collection, freeing objects you no longer use.
Examples
Java
// Compile to bytecode, then the JVM runs it:
// javac Main.java -> produces Main.class (bytecode)
// java Main -> JVM executes Main.class
System.out.println("Running on the JVM");Output:
Running on the JVM