Lesson 2 of 610 minModule progress 0%

Module 1: Start Coding in Java

Run Your First Java Code in the Browser Compiler

Use the built-in compiler to run Java without touching local setup yet, so you can focus on reading and editing code.

Author

Java Learner Editorial Team

Reviewer

Technical review by Java Learner

Last reviewed

2026-04-16

Java version

Java 25 LTS

How this lesson was prepared: AI-assisted draft, edited by hand, and checked against current Java 25 documentation and runnable examples.

Learning goals

  • Run a Java program in the site compiler
  • Edit the sample and rerun it
  • Read simple output without leaving the lesson flow

Before you start

  • You have opened the compiler or lesson page with the compiler launcher

Why this matters: The fastest way to start learning Java is to run code immediately. A browser-based compiler removes setup friction so you can focus on the language.

What to type: Use a full public class Main wrapper with a main method. That is the standard entry point for simple Java programs in this course.

How to experiment: Change one line, run again, and compare the new output. Small edits teach more than copying long examples you do not understand yet.

What to ignore for now: You do not need packages, IDE settings, build tools, or bytecode terms to finish your first few lessons successfully.

Runnable examples

First browser run

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello from Java Learner");
    }
}

Expected output

Hello from Java Learner

Change the text and rerun

public class Main {
    public static void main(String[] args) {
        System.out.println("I changed the sample.");
        System.out.println("Now I know the compiler works.");
    }
}

Expected output

I changed the sample.
Now I know the compiler works.

Common mistakes

Deleting the `main` method by accident

Keep `public static void main(String[] args)` intact while you are learning the structure.

Pasting only one statement instead of a full class

In this compiler, wrap your statements inside `public class Main` and the `main` method.

Mini exercise

Change the sample so it prints your name on one line and your goal on the next line.

Summary

  • The browser compiler is the fastest way to start.
  • Use a full `Main` class for beginner examples.
  • Change one thing at a time and rerun often.

Next step

Now that the program runs, break down the Hello World structure line by line.

Sources used

Advertisement

Lesson check

Why do we use the browser compiler first in this course?

Next lesson →