The Java Virtual Machine (JVM) is the program that reads and executes your compiled .class files. It sits between your bytecode and the operating system, translating instructions on the fly.
This is what makes Java portable. A .class file compiled on Windows runs on macOS or Linux without any changes, as long as a JVM is installed there. The slogan is "write once, run anywhere."
The JVM also handles memory allocation and garbage collection for you. When objects are no longer referenced, the JVM reclaims that memory automatically. Without this, you'd need to free memory manually like in C, which is a common source of crashes and security bugs.