How to Install the Java JDK on Windows, macOS and Linux
A step-by-step guide to installing Java 25 (LTS): choosing a JDK vendor, installing with an installer or package manager, setting PATH and JAVA_HOME, checking the install, and getting the library source code and API docs.
kvi5hnuCode Sprout team member13 min readOn this page
Before you can write Java programs, you need a Java Development Kit (JDK) on your computer. This article walks you through it on Windows, macOS and Linux. It also explains the jargon you'll meet on download pages, and how to fix the two problems beginners hit most: "command not found" and the wrong Java version.
By the end you'll have:
- a JDK installed (we recommend Java 25, the current LTS, or any newer version),
javaandjavacworking in a terminal,JAVA_HOMEset for tools that need it,- the Java library source code and API documentation at hand.
Step 1: Choose What to Download
Java download pages are full of acronyms. Here is what they mean and what to choose.
| Term | Meaning | What you want |
|---|---|---|
| JDK (Java Development Kit) | Compiler and tools plus a runtime | ✅ Yes, always the JDK |
| JRE (Java Runtime Environment) | Runtime only, no compiler | ❌ Not for development |
| SE (Standard Edition) | The core Java platform for desktops and servers | ✅ Yes |
| ME (Micro Edition) | Reduced Java for small devices | ❌ No |
| LTS (Long-Term Support) | A release that gets updates for years | ✅ Pick the latest LTS: 25 |
| OpenJDK | The open-source Java SE implementation every vendor builds from | Any OpenJDK build is fine |
| HotSpot | The standard JVM with its JIT compiler | ✅ If asked, choose HotSpot |
| OpenJ9 | An alternative JVM (Eclipse, originally IBM) | Works, but HotSpot is the default choice |
| GraalVM | A JDK with an advanced compiler and native image (ahead-of-time compilation into a standalone executable) | Not needed while learning |
| Temurin | The brand name of the Eclipse Foundation's OpenJDK builds | ✅ Recommended for this course |
| Adoptium | The Eclipse project that produces and tests Temurin | The website: adoptium.net |
| x64 / aarch64 (ARM64) | Processor architecture | Intel/AMD PCs → x64; Apple silicon Macs, ARM laptops, Raspberry Pi → aarch64 |
Which vendor?
The JDK is built by many organisations from the same OpenJDK source code: Eclipse Temurin (adoptium.net), Oracle (oracle.com/java and jdk.java.net), Amazon Corretto, Azul Zulu, Microsoft Build of OpenJDK, Red Hat, and others. For learning Java they are interchangeable; the brand only matters for licensing and paid support. This guide uses Eclipse Temurin 25, which is free, open source and available for every major platform.
Step 2: Install the JDK
You can install with a graphical installer or with a package manager. Package managers make upgrading later a one-line command.
Windows
Option A: the installer (simplest)
- Go to adoptium.net, choose Temurin 25 (LTS), operating system Windows, architecture x64 (or aarch64 on ARM laptops), package type JDK, and download the
.msifile. - Run it. On the Custom Setup screen, make sure these features are enabled (click each and choose "will be installed on local hard drive"):
- Add to PATH
- Set JAVA_HOME variable
- Finish the installer, then open a new terminal window (Command Prompt or PowerShell). Terminals that were already open don't see the new PATH.
Option B: winget (Windows Package Manager)
winget install EclipseAdoptium.Temurin.25.JDK
The JDK is installed into a folder such as C:\Program Files\Eclipse Adoptium\jdk-25.0.1.8-hotspot\. (The exact numbers depend on the update version.)
macOS
Option A: the installer
- On adoptium.net choose Temurin 25, macOS, and the right architecture: aarch64 for Apple-silicon Macs (M1 and later), x64 for older Intel Macs. (Not sure? Apple menu → About This Mac: "Chip: Apple M…" means aarch64.)
- Download the
.pkgfile and double-click it. Accept the defaults.
Option B: Homebrew
brew install --cask temurin@25
Either way, the JDK lands in a folder such as:
/Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home
macOS provides the commands /usr/bin/java and /usr/bin/javac as small launchers that automatically use the newest installed JDK, so on a Mac you usually don't need to edit PATH at all.
Linux
Option A: your distribution's packages
sudo apt update
sudo apt install openjdk-25-jdk
sudo dnf install java-25-openjdk-devel
The -jdk / -devel suffix matters: packages without it (openjdk-25-jre, java-25-openjdk) contain only the runtime, with no javac. On older distribution releases the version-25 package may not exist; in that case use option B, C or D.
Option B: the Adoptium repository (Temurin packages for Debian, Ubuntu, RHEL, Fedora, SUSE and Alpine). Follow the instructions at adoptium.net/installation/linux, then install temurin-25-jdk.
Option C: SDKMAN (handy if you need several versions side by side):
curl -s "https://get.sdkman.io" | bash
sdk install java 25-tem
Option D: a plain archive. Download the .tar.gz file and extract it anywhere, for example /opt:
sudo tar -xzf OpenJDK25U-jdk_x64_linux_hotspot_25.0.1_8.tar.gz -C /opt
ls /opt # shows something like jdk-25.0.1+8
Then add its bin folder to PATH (next step).
Step 3: Make Sure the Tools Are on the PATH
When you type a command like javac, your operating system doesn't search the whole disk. It looks only in the folders listed in an environment variable called PATH, in order, and runs the first match.

So the JDK's bin folder, which contains java, javac, jshell and the other tools, must be on the PATH. The installers usually do this for you. If not, here is how to do it manually.
Linux and macOS (bash or zsh): add these lines to the end of ~/.bashrc (bash) or ~/.zshrc (zsh, the default shell on macOS), using your actual JDK folder:
export JAVA_HOME=/opt/jdk-25.0.1+8
export PATH="$JAVA_HOME/bin:$PATH"
Then run source ~/.bashrc (or open a new terminal).
Putting $JAVA_HOME/bin before the old $PATH means your JDK wins if an older Java is also installed somewhere on the PATH.
Windows: press the Windows key, type environment variables, and choose Edit the system environment variables → Environment Variables…. Under User variables (or System variables), select Path → Edit → New, and add the JDK bin folder, for example C:\Program Files\Eclipse Adoptium\jdk-25.0.1.8-hotspot\bin. Use Move Up to place it above any other Java entries. Click OK everywhere, then open a new terminal.
What is JAVA_HOME?
JAVA_HOME is an environment variable that holds the JDK's installation folder (the folder that contains bin, not bin itself). The java and javac commands don't need it, but many tools look for it: Maven, Gradle, Tomcat, some IDEs and scripts. Set it once and save yourself trouble later. The installer or the snippet above does it; on Windows add a new variable named JAVA_HOME in the same dialog.
Step 4: Verify the Installation
Open a new terminal and run:
javac --version
java --version
You should see something like:
javac 25.0.1
openjdk 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)
The exact numbers will differ. What matters is that both commands work and that both show the same major version.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
javac: command not found (Linux/macOS) or 'javac' is not recognized as an internal or external command, operable program or batch file. (Windows) | The JDK bin folder is not on PATH, or you installed only a JRE | Add …/jdk-25…/bin to PATH; open a new terminal; install a package with -jdk/-devel |
java --version shows an older version than javac --version | Another Java appears earlier on PATH | Move your JDK's bin to the front of PATH; on Windows check for Oracle's javapath entry |
| It works in one terminal but not another | The other terminal was opened before you changed PATH | Close and reopen it (on Windows, sometimes sign out and back in) |
Unrecognized option: --version | A very old Java (8 or earlier) is being picked up; it only understands -version | Fix PATH so the new JDK comes first |
| Maven or Gradle uses the wrong Java | JAVA_HOME points to an old JDK | Update JAVA_HOME |
To find out which java is being used:
which -a java javac
where java
where javac
The first entry listed is the one that runs.
Step 5: Know Your JDK Folder
Wherever it was installed, the JDK folder looks like this:

| Platform | Typical JDK folder |
|---|---|
| Windows (Temurin) | C:\Program Files\Eclipse Adoptium\jdk-25.0.1.8-hotspot |
| Windows (Oracle) | C:\Program Files\Java\jdk-25 |
| macOS | /Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home |
| Linux (apt) | /usr/lib/jvm/java-25-openjdk-amd64 |
| Linux (archive) | wherever you extracted it, e.g. /opt/jdk-25.0.1+8 |
In this course we'll write jdk to mean "your JDK folder". For example, jdk/bin means the bin folder inside it, such as /opt/jdk-25.0.1+8/bin.
Don't worry if your JDK has no jmods folder. Since JDK 24 (JEP 493), vendors may build a JDK without it to save space, and jlink can then build runtime images from the JDK's own runtime instead. Nothing in this course depends on that folder.
The release file is a quick way to identify a JDK: cat jdk/release prints its version, vendor and architecture.
Step 6: Get the Library Source Code
One of the best ways to learn Java is to read the source code of the standard library: how String, ArrayList or HashMap actually work. The JDK ships that source in jdk/lib/src.zip.
IDEs read src.zip automatically: Ctrl-click (Cmd-click on macOS) on ArrayList in IntelliJ IDEA or Eclipse and the real source opens. To browse it yourself, unpack it:
mkdir javasrc
cd javasrc
jar xf "$JAVA_HOME/lib/src.zip"
cd ..
(jar is the JDK's archive tool, so this works the same on every operating system. On Windows use "%JAVA_HOME%\lib\src.zip" in Command Prompt or "$env:JAVA_HOME\lib\src.zip" in PowerShell. Any unzip tool works too.)
Inside you'll find a folder per module. For example, java.base/java/lang/String.java is the source of the String class.
Some Linux packages leave out src.zip. On Debian/Ubuntu, install openjdk-25-source to get it.
Step 7: Bookmark the API Documentation
The Java API documentation (the "Javadoc") describes every public class and method in the standard library. You'll use it constantly. The online version for Java 25 is at:
https://docs.oracle.com/en/java/javase/25/docs/api/
(Replace 25 with your version.) Use the search box at the top right: type String, ArrayList or LocalDate to jump straight to a class.
If you want an offline copy, download the documentation bundle (jdk-25…_doc-all.zip) from Oracle's Java downloads page, unzip it, rename the docs folder to something descriptive like jdk-25-docs, and bookmark jdk-25-docs/index.html in your browser.
Common questions
Should I install the newest release or the LTS?
For this course, Java 25 (LTS) is the safe choice, and any newer release also works. Work projects usually pin an LTS. Having both installed causes no problems, because each lives in its own folder and you pick one with PATH, JAVA_HOME or your IDE.
java -version and javac -version show different numbers. Is that a problem?
Yes. It means your PATH finds java from one installation and javac from another, usually an old runtime that sits earlier on the PATH. Put your JDK's bin folder first, open a new terminal, and check both again. Classes compiled by a newer javac fail on an older java with UnsupportedClassVersionError.
What does UnsupportedClassVersionError ... class file version 69.0 mean?
The class was compiled for a newer Java than the one running it. Class file version 69 is Java 25, 68 is Java 24, 65 is Java 21 and 61 is Java 17. Either run it with a newer JDK, or compile for the older target with javac --release 21 ....
Do I need admin rights to install a JDK?
No, if you use a plain archive. Extract the .zip or .tar.gz into a folder you own and add its bin folder to your user PATH. SDKMAN also installs into your home directory. The installers and system package managers need admin rights.
Is JAVA_HOME the folder with bin or the bin folder itself?
It is the folder that contains bin, for example /opt/jdk-25.0.1+8. PATH gets $JAVA_HOME/bin. Setting JAVA_HOME to the bin folder is a common mistake that breaks Maven and Gradle.
Summary
- Install a JDK (not just a JRE), preferably Java 25 LTS. Eclipse Temurin is a good free choice, and any OpenJDK build works.
- Use the installer, or a package manager: winget (Windows), Homebrew (macOS), apt/dnf or SDKMAN (Linux).
- The JDK's
binfolder must be on PATH; setJAVA_HOMEto the JDK folder for build tools. - Verify with
javac --versionandjava --versionin a new terminal; both should show the same version. - Library source is in
jdk/lib/src.zip; API docs are at docs.oracle.com/en/java/javase/25/docs/api/.
Practice Questions
You type javac and get "command not found", but java works. What's going on?
Either you installed only a runtime (JRE package such as openjdk-25-jre), which has java but not javac, or the java being found belongs to a different installation whose bin folder has no compiler. Install the full JDK package and make sure the JDK's bin folder is on PATH.
Should JAVA_HOME point to jdk-25 or to jdk-25/bin?
To the JDK's top folder, jdk-25, not bin. Tools build paths such as $JAVA_HOME/bin/java themselves. PATH, on the other hand, must contain the bin folder.
java --version prints 17 but javac --version prints 25. Why, and how do you fix it?
Two Java installations are on the PATH, and the folder containing an older java comes before the JDK 25 bin folder. (On Windows, Oracle's javapath folder is a common culprit.) Move the JDK 25 bin entry to the front of PATH, open a new terminal, and check with where java / which -a java.
You changed PATH, but your open terminal still can't find javac. Why?
Environment variables are copied into a process when it starts. A terminal that was already open keeps its old copy. Open a new terminal (or run source ~/.bashrc / source ~/.zshrc on Linux/macOS).
Which file contains the source code of java.lang.String, and why would you read it?
jdk/lib/src.zip, at java.base/java/lang/String.java inside the archive. Reading library source shows how the classes really work (how strings are stored, how ArrayList grows), and IDEs open it for you when you Ctrl/Cmd-click a class name.
Previous: Java Myths and Misconceptions: What Java Is and Isn't
Next: How to Compile and Run Java Programs from the Command Line
Related reading
- JShell Tutorial: Java's Interactive REPL for Quick Experiments
- Using a Java IDE: IntelliJ IDEA, VS Code and Eclipse for Beginners
- How to Compile and Run Java Programs from the Command Line
- Java Collectors.toMap: Collecting Streams into Maps
- Collecting Java Stream Results: toList, toArray, joining and Summary Statistics

More in Core Java I
Java volatile, Atomics, Deadlocks and ThreadLocal: Safe Sharing Between Threads
Share data between Java threads without bugs: memory visibility and volatile, final fields, AtomicInteger and compareAndSet, LongAdder, lazy holder initialization, safe publication, lock-ordering deadlocks, ThreadLocal, InheritableThreadLocal and ScopedValue.
Java Condition Objects and the synchronized Keyword: await, signalAll, wait and notify
Make threads wait for a condition safely with Condition.await and signalAll, then learn Java's built-in alternative: synchronized methods and blocks, intrinsic locks, wait and notifyAll, choosing lock objects, client-side locking, and the monitor concept.
Java Race Conditions and ReentrantLock: Synchronizing Shared Data
Why unsynchronized threads corrupt shared data, shown step by step with a lost-update race, and how to fix it with ReentrantLock: the lock/try/finally idiom, critical sections, reentrancy and hold counts, tryLock, fair locks, and the mistakes that cause bugs.
Java invokeAll, invokeAny and Fork-Join: Running Groups of Tasks
Coordinate many concurrent tasks in Java: invokeAll to wait for every result, invokeAny to take the first success, timeouts, ExecutorCompletionService for results in completion order, structured concurrency, and the fork-join framework with RecursiveTask, RecursiveAction and work stealing.
Discussion
Sign in to ask a question or share what you learned.