Start Learning
Javaneer
Back to stage
Stage 0·Meet Java

Setup & Hello, World!

Install a JDK, pick an IDE, and write, compile, and run your very first Java program step by step.

16 min readBeginner
On this page

This is the moment it becomes real. In this lesson you'll install Java, choose a place to write code, and run your very first program. Follow along - by the end you'll have made a computer print words on screen with code you wrote yourself.

Step 1 - Install a JDK

You need the JDK (Java Development Kit). A great, free, no-fuss choice is Eclipse Temurin.

  1. Go to adoptium.net.
  2. Download the latest LTS version (Java 21 or newer) for your operating system (Windows, macOS, or Linux).
  3. Run the installer and accept the defaults.

To confirm it worked, open a terminal (Command Prompt on Windows, Terminal on macOS/Linux) and type:

java -version

You should see something like openjdk version "21.0.1". If you do - congratulations, Java is installed! 🎉

'java' is not recognized?

If the terminal says the command isn't found, the installer may not have added Java to your system PATH. Re-run the installer and enable the "Add to PATH" option, or restart your terminal (and computer) and try again.

Step 2 - Choose where to write code

You could write Java in a plain text editor, but a proper tool makes learning far easier by highlighting mistakes and helping you run code.

  • IntelliJ IDEA (Community Edition) - the most popular Java IDE; free and beginner-friendly. Recommended.
  • Visual Studio Code - lightweight; add the "Extension Pack for Java".
  • Eclipse - a long-standing, free Java IDE.
An IDE is like a writing assistant

Writing code in Notepad is like writing an essay with no spell-check - every typo is invisible until it's too late. An IDE (Integrated Development Environment) is like a smart writing assistant: it underlines mistakes as you type, suggests words, and even runs your program with one click.

Step 3 - Write "Hello, World!"

By tradition, every programmer's first program simply prints "Hello, World!". Create a file named Hello.java and type this in exactly:

public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Type it, don't paste it

Actually typing the code - even when it feels slow - helps your brain absorb the structure far better than copying and pasting. Make the typos; fixing them is how you learn.

Step 4 - Run it

In an IDE: click the green ▶ "Run" button next to the main method.

From the terminal, in the folder containing your file:

javac Hello.java
java Hello

The first line compiles your code into bytecode (Hello.class); the second runs it. You should see:

Output

Hello, World!

You just wrote and ran your first Java program. That's genuinely a big deal - the same fundamental steps power software running on billions of devices.

What did each part mean?

Don't worry about memorizing this - we'll unpack every piece in Stage 1. Just a first taste:

  • public class Hello - defines a class named Hello (your program lives inside a class). The file name must match: Hello.java.
  • public static void main(String[] args) - the main method, the exact entry point where Java starts running your program.
  • System.out.println("Hello, World!"); - prints a line of text to the screen. Every statement ends with a semicolon ;.

Quick check

What must the file be named if it contains 'public class Hello'?

Key takeaways

  • Install the JDK (Eclipse Temurin is a great free choice) and verify with 'java -version'.
  • Use an IDE like IntelliJ IDEA Community Edition to catch mistakes and run code easily.
  • A public class must be saved in a file with a matching name, e.g. Hello.java.
  • Compile with 'javac Hello.java', then run with 'java Hello'.
  • System.out.println(...) prints a line of text; every statement ends with a semicolon.

You've finished Stage 0! You understand what Java is, where it came from, how it runs, and you've written real code. Next up: Stage 1, where we start building actual programs with variables, types, and logic.