Java chapters

Chapter 2 of 17

Setting up Java

Try this in our Java Compiler →

Tools you need

To write and run Java you need three things: a place to write code (any text editor such as VS Code works), a way to run the code (an interpreter or compiler for Java), and a terminal where you can type commands. Most modern editors bundle a terminal so you only need to install one program.

Your first file

Create a file named hello.java and paste in the snippet below. Save the file, then run it from your terminal. If you see the words "Hello, World!" printed back, your installation is correct and you are ready to learn the rest of the language.

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

Common installation issues

If the command is not recognised, the language is not on your system PATH. Reinstall and tick "add to PATH" if the option is offered. On a school or work machine where you cannot install software, use any online playground — the code in this course runs unchanged in a browser-based editor.

Try it yourself

Java Compiler
Output
Code runs on the Play with Coding execution engine — your code is saved locally for next time.