Install the JDK and an editor
Install a free JDK on Windows, macOS or Linux, check it works, and set up IntelliJ IDEA or VS Code for writing Java.
To write Java you need two things: the JDK (which contains the compiler and the JVM) and an editor to type your code in. Both are free. This lesson takes about 15 minutes.
01Which JDK to install
Several companies build free JDKs from the same open-source code (OpenJDK). They behave the same for learning. We recommend Eclipse Temurin, from adoptium.net.
Pick the latest LTS (Long-Term Support) version. LTS versions get updates for years, and companies use them in production. Every example in this track works on Java 21 or newer.
02Install on Windows
- Go to adoptium.net and download the .msi installer for Windows x64.
- Run it. On the "Custom setup" screen, turn on Set JAVA_HOME variable and Add to PATH.
- Finish the installer, then open a new Command Prompt or PowerShell window.
03Install on macOS
The easiest way is Homebrew:
brew install --cask temurinOr download the .pkg installer from adoptium.net and double-click it.
04Install on Linux
On Ubuntu or Debian, the OpenJDK package works well:
sudo apt update
sudo apt install openjdk-21-jdkUse the newest version number your distribution offers.
05Check it works
Open a new terminal and run:
java -version
javac -versionYou should see version numbers for both. If you see "command not found" or "'java' is not recognized", the JDK isn't on your PATH. Reopen the terminal first; on Windows, run the installer again and tick Add to PATH.
06Choose an editor
| Editor | Good for | Cost |
|---|---|---|
| IntelliJ IDEA Community | The most popular Java IDE. Great code completion, debugging and refactoring | Free |
| VS Code with the "Extension Pack for Java" | Lightweight, good if you already use VS Code | Free |
| A plain text editor + terminal | Understanding exactly what happens. Good for the first few lessons | Free |
We suggest IntelliJ IDEA Community Edition from jetbrains.com/idea. When you create your first project, choose the JDK you just installed.
07No install? Try it online
While you set things up, you can run any example right inside these lessons: click ▶ Run on a code block. A live editor opens with the example already loaded and running, and you can change the code and run it again.
08Check your understanding
Quiz · 4 questions
0 of 4 answered
1. What should you install to write and compile Java programs?
2. Why choose an LTS version of Java?
3. java -version works but javac -version says "not found". What's the likely problem?
4. You installed the JDK but java isn't recognised in your terminal. What should you try first?