Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

How Java Works · Lesson 8 of 28

Java Virtual Machine (JVM)

A free lesson from Swipe Coding · Java, level 1 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
Bytecode needs someone to actually run it — say hello to the JVM. 👋

You have learned that the compiler produces bytecode (a .class file) from your source code. But who actually executes this bytecode? The answer: the "Java Virtual Machine", or JVM for short.

The JVM is a program that runs on your operating system and reads bytecode. It translates the bytecode step by step into the machine language that your specific device's processor understands — whether that's a Windows PC, a Mac, or a Linux server.

java Main
This is how you start the JVM on the command line: "java" plus the name of the compiled class (without .class).
Fill in the blank

The JVM translates ____ into machine language for the respective processor.

🤖
Bytecode is universal, but is the JVM itself the same everywhere? Think before you answer. 🤔

Every operating system has its own matching version of the JVM. This is exactly why "Write once, run anywhere" works: you write your code once, compile it once into bytecode — and it can be executed anywhere a matching JVM is installed.

True or false

Windows, macOS, and Linux each have different versions of the JVM.

🤖
Watch how these three pieces line up into one complete pipeline. 🔗

The complete process looks like this: you write Main.java (source code). The compiler javac translates it into Main.class (bytecode). The JVM reads Main.class and executes it by translating it into machine language for your device.

Quick check

What is the main task of the Java Virtual Machine (JVM)?

🤖
Without this piece, none of the bytecode magic would matter at all. 🔑

The JVM is thus the crucial link between platform-independent bytecode and the actual device your program is meant to run on. Without a JVM, no Java program could be executed.

True or false

Without an installed JVM, a device cannot execute Java bytecode files.

Keep your streak going in Swipe Coding

Swipe through every level of Java on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.

Get the Swipe apps →