One thing: something that can compile and run Java and show you what it prints. That is the entire requirement for all four units. Nothing in this course needs a graphics library, a database, or a package manager.
Two pieces, if you are starting from nothing:
If you already have Java running some other way — a different editor, a JDK that came with something else, a command line you like — keep it. Every program in this course is a single plain .java file with no dependencies, so it runs anywhere Java runs, and nothing on these pages depends on which editor you used.
Make a folder to keep this course's work in and open it in VS Code — File > Open Folder. Inside it, make a file called Main.java and put this in it. Type it rather than pasting it — there is a reason, and it is the next section.
public class Main{ public static void main(String[] args) { System.out.println("Ready."); }}Press the Run button — the ▷ at the top right, or the Run link the extension puts just above main. A terminal panel opens at the bottom and shows:
Ready.The file name has to match the class name. A class called Main lives in a file called Main.java, capital M and all. This is a rule Java actually enforces, and it is the first thing that catches people arriving from Python or JavaScript.
No Run button? The Java extension pack is not installed, or it has not found a JDK — those are the only two reasons. Nothing here needs a project, a build file, or a src folder: one loose .java file in an open folder is a complete, runnable program.
This is the section worth reading twice. If your last language was Python or JavaScript, Java fails at different times than you are used to, and the whole experience of writing it depends on recognizing which kind of failure you are looking at.
The program is not valid Java, so it never runs at all. Drop one semicolon:
public class Main{ public static void main(String[] args) { System.out.println("Ready.") }}Main.java:5: error: ';' expected System.out.println("Ready.") ^1 errorNote what you get: a file, a line number, and a caret pointing at the character. Compiler errors look hostile and are in fact the most helpful message in the language. Read the first one, fix it, recompile. Do not read all forty — one mistake often produces a cascade, and the first line is usually the only real one.
This is the category that does not exist in a dynamically typed language, and it is the reason Java feels strict at first:
int score = "seven";Main.java:5: error: incompatible types: String cannot be converted to int int score = "seven"; ^In Python this line runs fine and blows up somewhere else, later, with a stack trace that points at the wrong place. In Java it is caught before the program ever starts. You will trade a slower start for far fewer mysteries at 11pm. That trade is most of what static typing buys you.
The code was valid. It just asked for something impossible once it was running:
int[] scores = new int[3];System.out.println(scores[3]);Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:Index 3 out of bounds for length 3 at Main.main(Main.java:6)An array of length 3 has indexes 0, 1, and 2. There is no index 3. Read the exception name first — ArrayIndexOutOfBoundsException says exactly what happened — then read the line number.
There is a fourth kind, and it is the worst: the program compiles, runs, finishes, and prints the wrong answer. Nothing tells you. That one is on you to catch, and it is what the debug challenges in this course are for.
Every code sample in this course puts an opening brace on its own line:
public class Main{ public static void main(String[] args) { System.out.println("Ready."); }}You will see Java written the other way, with the brace at the end of the previous line, and both are correct. Java does not care and neither does the exam. Pick one and be consistent; this course is consistent about this one so that the block structure is easy to see at a glance while you are still learning to read it.
If your editor reformats a file and moves the braces up a line, that is its formatter applying its own default — not a mistake, and not something you need to fight. It changes nothing about how the program runs.
If Ready. printed, you have everything you need for the whole course. Read The Exam, and How to Pace Yourself before starting Unit 1 — it is short, and it will change how you use the rest of these pages.