Installing the JDK
Before you can cook, you need a kitchen. Before you can write Java, you need the JDK on your computer. It takes about ten minutes, and you only do it once. By the end of this lesson, typing java -version in a terminal will print 25, and you'll be ready to write your first program.
What You Are Installing
The JDK (Java Development Kit) is one download that contains everything you need:
| Part | What it does |
|---|---|
javac | The compiler: turns your .java files into bytecode |
java | The launcher: starts the JVM and runs your program |
| The JVM | Runs the bytecode on your computer |
| The standard library | Ready-made classes for text, dates, files, networking and more |
| Tools | jshell, javap, jar and others you'll meet later |
This course uses Eclipse Temurin 25, a free build of OpenJDK. The lesson "JDK Distributions" explains why there are several builds and why any of them works the same for your code.
Check Whether Java Is Already Installed
Open a terminal first:
- Windows: press the Windows key, type
cmd, and press Enter. - macOS: press Cmd + Space, type
Terminal, and press Enter. - Linux: press Ctrl + Alt + T on most desktops.
Then type this command and press Enter:
java -versionIf you see a version number of 25 or higher, Java is already installed and you can skip to "Check That It Works". If you see command not found, 'java' is not recognized, or an older version such as 17 or 1.8, install JDK 25 using the steps below.
Install JDK 25
Pick your operating system.
1. Open https://adoptium.net in your browser.
2. Choose: Operating System = Windows, Architecture = x64,
Package Type = JDK, Version = 25 - LTS.
3. Download the .msi file and double-click it.
4. On the "Custom Setup" screen, set these two options to
"Will be installed on local hard drive":
- Set JAVA_HOME variable
- Add to PATH
5. Click Next, then Install. Close and reopen any terminal.Option A: installer
1. Open https://adoptium.net in your browser.
2. Choose: Operating System = macOS, Package Type = JDK,
Version = 25 - LTS. Pick aarch64 for Apple silicon
(M1 and later) or x64 for older Intel Macs.
3. Download the .pkg file, double-click it and follow the steps.
Option B: Homebrew (if you already use it)
brew install --cask temurin@25Ubuntu and Debian, when your release offers JDK 25:
sudo apt update
sudo apt install openjdk-25-jdk
Fedora:
sudo dnf install java-25-openjdk-devel
Any distribution: download the .tar.gz for Linux from
https://adoptium.net, extract it (for example to /opt), and
add its bin folder to PATH (next lesson).The Windows installer can set JAVA_HOME and PATH for you, which is why step 4 matters. On macOS and Linux the installers usually put java on your PATH automatically. The next lesson explains both settings properly.
Check That It Works
Close the terminal and open a new one. A terminal reads its settings only when it starts. Then run both commands:
java -version
javac -versionYou should see output like this. The exact numbers and build names depend on the update you installed:
openjdk version "25.0.1" 2025-10-21 LTS
OpenJDK Runtime Environment Temurin-25.0.1+8 (build 25.0.1+8-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.1+8 (build 25.0.1+8-LTS, mixed mode, sharing)
javac 25.0.1Both commands must work. If java works but javac doesn't, you have a runtime without the compiler, and you need to install the JDK.
Your First Check in Java
Once Java runs, this small program reports which Java it's running on and where it is installed. You'll learn how to run a .java file in the next few lessons. For now, you can press Try it to see what it does.
public class InstallCheck {
public static void main(String[] args) {
String version = System.getProperty("java.version");
String vendor = System.getProperty("java.vendor");
String home = System.getProperty("java.home");
System.out.println("Version: " + version);
System.out.println("Vendor: " + vendor);
System.out.println("Home: " + home);
}
}Version: 25.0.1
Vendor: Eclipse Adoptium
Home: C:\Program Files\Eclipse Adoptium\jdk-25.0.1.8-hotspotHow it works
- Lines 3 to 5 read three system properties: values the JVM fills in when it starts.
java.homeis the folder the running Java was installed in. You'll need this path when you setJAVA_HOMEin the next lesson.- Lines 7 to 9 print them. The extra spaces after
Vendor:andHome:just line the values up.
Try it yourself: after you install, run this on your own computer. Does the version say 25?
Common Mistakes
Using the terminal that was already open. A terminal opened before the installation doesn't know about the new Java. Close it and open a new one.
Installing an old version from an old tutorial. Many websites still link to Java 8 downloads. This course uses features up to Java 25, so check the version before you download.
Having two versions and getting the wrong one. It's fine to have Java 17 and Java 25 installed together, but the one listed first on your PATH wins. If java -version shows the wrong one, the next lesson shows how to fix it.
Practice
- Easy: Install JDK 25 and run
java -versionandjavac -version. Write down the exact version and vendor you see. - Harder: Run
InstallCheckand find the folder printed afterHome:in your file explorer. Open itsbinfolder. Which programs do you recognize from the table at the top of this lesson?
Key Takeaways
Was this tutorial helpful?