Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

How Java Works · Lesson 7 of 28

Bytecode

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

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

🤖
Compiling does not produce a finished program yet — there is a step in between. 🔍

When the compiler ("javac") translates your source code, the result is not a finished file for Windows, macOS, or Linux — but "bytecode". Bytecode is an intermediate form: no longer human-readable text, but also not machine language for a specific processor.

Bytecode is saved in a new file with the extension ".class". So after compiling, "Main.java" becomes "Main.class".

javac Main.java
// produces: Main.class
The compiler reads Main.java and produces the bytecode file Main.class from it.
Fill in the blank

Bytecode files in Java have the file extension ____.

What is special about bytecode is that it is platform-independent. This means the same .class file can be used on a Windows PC, a Mac, or a Linux server — the bytecode itself is identical everywhere. No recompiling needed for each operating system!

True or false

Bytecode is different for each operating system and must be freshly generated for Windows, macOS, and Linux.

🤖
This combo is exactly what makes write once, run anywhere possible. 🌐

Bytecode still isn't what the processor directly understands, though. It is a kind of "intermediate language", made specifically to be read by another program — the Java Virtual Machine (JVM), which you will learn about in the next lesson. It is exactly this combination of bytecode and JVM that makes Java's motto "Write once, run anywhere" possible.

Quick check

Why is bytecode so important for Java?

🤖
One more piece of the puzzle before the JVM takes center stage. ➡️

In summary: source code (.java) is translated by the compiler into bytecode (.class). Bytecode is not yet machine language, but a platform-independent intermediate form waiting to be executed.

True or false

Bytecode is created when the compiler translates a .java file.

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 →