Installing the JDK

Naveen AnamaneniUpdated · 6 min read

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:

PartWhat it does
javacThe compiler: turns your .java files into bytecode
javaThe launcher: starts the JVM and runs your program
The JVMRuns the bytecode on your computer
The standard libraryReady-made classes for text, dates, files, networking and more
Toolsjshell, 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:

Terminal
java -version

If 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.

Steps
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.

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:

Terminal
java -version
javac -version

You should see output like this. The exact numbers and build names depend on the update you installed:

Output
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.1

Both 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.

InstallCheck.java▶ Try it
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);
    }
}
Output
Version: 25.0.1
Vendor:  Eclipse Adoptium
Home:    C:\Program Files\Eclipse Adoptium\jdk-25.0.1.8-hotspot

How it works

  1. Lines 3 to 5 read three system properties: values the JVM fills in when it starts.
  2. java.home is the folder the running Java was installed in. You'll need this path when you set JAVA_HOME in the next lesson.
  3. Lines 7 to 9 print them. The extra spaces after Vendor: and Home: 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

  1. Easy: Install JDK 25 and run java -version and javac -version. Write down the exact version and vendor you see.
  2. Harder: Run InstallCheck and find the folder printed after Home: in your file explorer. Open its bin folder. Which programs do you recognize from the table at the top of this lesson?

Quick check: Installing the JDK

4 questions
1Which tool is in the JDK but not in a runtime-only installation?
2You installed JDK 25, but java -version in your open terminal still says "not recognized". What should you try first?
3On the Windows installer, which two options should you turn on?
4Which command shows the version of the compiler?

Key Takeaways

Was this tutorial helpful?

Lesson 10 of 482