Set Up Your Language · 5 of 14
Setting Up Java
Java is one of the most widely used languages for large business systems, banking software and, historically, Android apps. Java programs run on the Java Virtual Machine, so the same program works on Windows, Mac and Linux. To write Java you need a JDK (Java Development Kit). We use Eclipse Temurin, a free, official build of Java from the Eclipse Foundation's Adoptium project.
New to all this? Read Before you start on the main page first: it shows how to open Terminal, make a folder for your code, and see file name endings. It takes five minutes and prevents most problems.
1 What to download, and from where
Download only from adoptium.net, the Eclipse Foundation's Adoptium project (Oracle's own JDK at oracle.com/java is the other official choice). Other download sites can bundle unwanted software.
- Go to adoptium.net.
- Click the big download button for the latest LTS version of Temurin (LTS = Long-Term Support, the stable version). The site usually detects Windows x64 for you; check that the file ends in .msi.
2 Install it on Windows
- Open the downloaded
.msifile. Click Next and accept the licence. - On the Custom Setup screen you see a list of features with small drive icons. Click the icon next to Set JAVA_HOME variable and choose Will be installed on local hard drive. Leave Add to PATH as it is (already on). Some tools look for JAVA_HOME, so this saves trouble later.
- Click Next, then Install, then Yes if Windows asks, then Finish.
3 Check that it worked
Close every Terminal window you have open and open a new one. A Terminal that was already open does not know about programs installed after it started. Then type this and press Enter:
java -version
javac -versionWhat you will see: java runs programs and javac builds them; both should show the same version number.
openjdk version "25.0.1" 2025-10-21 LTS ... javac 25.0.1
If you see an error such as "is not recognized" instead, look at the common mistakes at the bottom of this page.
4 Write and save your first program
A program is just a text file. You can write it in Notepad, which comes with Windows. (Later you may like the free Visual Studio Code editor from code.visualstudio.com, which colours the code and helps spot mistakes.)
- Open Notepad (press the Windows key, type Notepad, press Enter).
- Type the program below, or click Copy and paste it in with Ctrl + V. Every symbol matters, so copy it exactly.
public class Hello { public static void main(String[] args) { System.out.println("Hello, World!"); } } - In Notepad choose File → Save as. Go to your
C:\codefolder. Set Save as type to All files (*.*), type the file nameHello.javaexactly as shown, including the dot and the ending, and click Save.
Every Java program lives inside a class, here named Hello; main is where it starts; System.out.println prints a line. Note the capital H in the file name: it must match the class name.
Do not use Word. Word saves extra formatting and changes straight quotes " into curly ones “ ”, which no programming language accepts.
5 Run it and see the result
Open File Explorer, go into your C:\code folder, right-click an empty part of the window and choose Open in Terminal. (More ways to open Terminal.) If Terminal was already open from the check above and is in another folder, type cd C:\code and press Enter.
Type this and press Enter:
java Hello.javaWhat you will see: the words below on a new line. That is your program running.
Hello, World!
This runs the file straight away. The traditional way, still common, is two steps: javac Hello.java builds Hello.class, then java Hello runs it.
Congratulations: you have written and run a Java program.
6 Common beginner mistakes and how to fix them
Error messages look alarming but are usually precise: read the first line, and look for a line number. If you are stuck, copy the whole error message and paste it into an AI assistant along with your code, and ask what it means.
error: class Hello is public, should be declared in a file named Hello.java
Why: in Java the file name must match the class name exactly, including capital letters.
Fix: rename the file to Hello.java (capital H), or change the class name inside the file to match.
error: package system does not exist
Why: Java is case-sensitive: system.out.println is wrong.
Fix: write System with a capital S. The same goes for String.
'java' is not recognized as an internal or external command
Why: Windows cannot find the program. Either the Terminal was open before you installed it, or the program's folder is not on the PATH (the list of folders Windows searches for commands).
Fix: Close every Terminal window you have open and open a new one. A Terminal that was already open does not know about programs installed after it started. If it still fails, restart the computer, then check the folder is on the PATH (how to check and add it).