Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

How Java Works · Lesson 6 of 28

Compiler

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

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

🤖
Your code needs a translator before the computer can run it — meet the compiler. 🔧

You now know that source code is human-readable, but the computer cannot execute it directly. This is exactly where the "compiler" comes in — a program that translates your source code.

The Java compiler is called "javac" (short for "Java Compiler"). It reads your .java file and translates it into a new file that the computer can process more easily. This process is called "compiling".

javac Main.java
This is how you call the compiler on the command line: "javac" plus the name of your source code file.
Fill in the blank

The Java compiler is called ____.

🤖
Bytecode is the next big idea — we dig into it properly next lesson. 👀

Important: the compiler does not translate your code directly into machine language for a specific processor. Instead, it produces a special intermediate form called "bytecode" — more on that in the next lesson. This intermediate form is the trick that makes Java runnable on so many different devices.

The compiler also checks your code for errors. If, for example, you made a typo or forgot a bracket, the compiler stops with an error message and does not produce a translated file. This is called a "compile error".

Quick check

What happens if your Java source code contains a typo?

🤖
That translator analogy is a good one to hold onto — think it through before you answer. 🕵️

You can think of the compiler like a translator converting a book from one language into another — except it also checks every sentence for grammar mistakes before translating it.

True or false

The Java compiler translates source code directly into machine language for a specific processor.

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 →