Install Java¶
You will install the Java Development Kit, confirm from a terminal that it is the version this course uses, and understand what you just put on your machine. After this page you can compile and run Java without any editor at all.
Java is not one program. It is a compiler, a runtime and a set of tools, and the difference between them is behind most of the confusing errors beginners hit. Ten minutes here saves an afternoon in week three.
What a JDK actually contains¶
A JRE can run Java. It cannot compile it. That is the whole distinction, and it is why installing a JRE by mistake produces a machine that runs other people's programs but not your own.
1. Install Temurin 25¶
This course uses Eclipse Temurin 25, which is the free OpenJDK build published by the Eclipse Adoptium project.
Open PowerShell and run:
Close PowerShell when it finishes and open a new one. The installer changes your PATH, and an already-open terminal will not see the change.
If winget is not available
winget ships with Windows 11 and recent Windows 10. If the command is not recognised, download the MSI installer instead.
- Go to adoptium.net/temurin/releases
- Choose Windows, x64, JDK, version 25
- Download the
.msifile and run it - On the setup options screen, turn on Set JAVA_HOME variable and Add to PATH
Those two options are off by default and they are exactly the ones you need.
Do not download Java from Oracle
Oracle's own build is a different product with different licence terms that have changed more than once, and some downloads want an account. Temurin is built from the same OpenJDK source, it is free for any use, and nothing in this course can tell the difference. If you already installed Oracle's version, uninstall it before continuing so you do not end up with two.
2. Check that it worked¶
In a new PowerShell window:
Both should report version 25. Something like this:
The important part is the number at the front. The digits after the dot will differ from the example and that is fine.
javac works but java shows a different version
That means you have more than one Java on the machine and the two commands are finding different ones. It will not cause an error today. It will cause a confusing one in week six. Uninstall the versions you do not need from Settings then Apps, then check both commands again.
3. Run something without an editor¶
You do not need Eclipse to write Java. Proving that now makes the next page make sense.
Start jshell, which is Java's interactive prompt:
Type this at the jshell> prompt and press Enter:
Then type /exit to leave.
If that printed a line starting with Running on 25, your toolkit is installed, correct, and working. Everything from here is convenience.
When it goes wrong¶
'java' is not recognized as an internal or external command
Windows cannot find the program. Two likely causes.
You did not open a new terminal. PATH changes only apply to windows opened afterwards. Close PowerShell, open it again, try again.
PATH was not updated during install. If you used the MSI and left the default options, this is what happened. Run the installer again, choose Change, and turn on Set JAVA_HOME variable and Add to PATH.
Check what Windows can actually see:
No output means nothing is on your PATH.
The version number is not 25
An older Java was already installed and is being found first. See which ones are present:
If more than one path appears, remove the ones you do not want through Settings then Apps, then open a new terminal and check again.
java works but javac does not
You have a JRE, not a JDK. The runtime is installed and the compiler is not. Go back to step 1 and make sure you are installing the package ending in .JDK.
winget says the package was not found
Your package source is out of date. Refresh it and try again:
If it still fails, use the MSI installer from the collapsed block in step 1.
Check yourself¶
Prove the toolkit is complete
Make a folder, write a file by hand, compile it and run it. No editor involved.
Create Check.java in Notepad with exactly this:
public class Check {
public static void main(String[] args) {
System.out.println("Compiled and running on " + Runtime.version());
}
}
Then:
You should see a Check.class file appear, and a line printed starting with Compiled and running on 25. You have now used both halves of the JDK, and you have seen the class file that the diagram at the top of this page was talking about.
Think about it¶
- Temurin and Oracle's build come from the same OpenJDK source and produce the same output. So what were you actually choosing between? Now imagine you are at a company with four hundred developers and someone from finance asks what the Java on those machines costs.
- Compiling and running are two separate commands. Why split them at all, instead of one command that just runs your file? Now think about sending your finished program to someone who will never edit it. Which of the two do they need?
- Something on your machine is "the default Java". Where does that setting actually live? Next year a different course asks you to install Java 21 alongside this one. What breaks, and what would you want to have set up today to make that painless?
- The
.classfile you produced is not readable and not the thing you wrote. Why does Java do this, when some languages run your source directly? Consider what has to be true for that class file to run on a machine that is not yours.