How to install Java (OpenJDK) on Windows, Mac and Linux
By Pull This RepoPosted 5 min read
Short answer
For a free Java install, use Eclipse Temurin, the OpenJDK build from Adoptium. Java 25 is the current long-term support release. On Windows run winget install EclipseAdoptium.Temurin.25.JDK, on a Mac run brew install --cask temurin@25, and on Debian or Ubuntu add Adoptium's apt repository and install temurin-25-jdk. Then run java -version to check.
The simplest free Java install is Eclipse Temurin, the OpenJDK build published by the Eclipse Adoptium project. It installs like any other app on Windows, macOS and Linux, needs no account, and is free for any use. This guide gives the one command for each system, how to set JAVA_HOME, how to check it worked, and what Oracle's own JDK licence says. Versions, commands and licence terms were read on Adoptium's, Homebrew's and Oracle's own pages on 22 November 2026.
Which Java version should you install?
Install Java 25 unless a program tells you otherwise. Adoptium's release API listed these on 22 November 2026:
| Version | Type | Notes |
|---|---|---|
| Java 25 | Long-term support (LTS) | The most recent LTS; latest Temurin build jdk-25.0.5.1+2 |
| Java 21 | LTS | Older LTS, still offered |
| Java 17, 11, 8 | LTS | For older apps that need them |
| Java 27 | Feature release | The newest release; replaced by the next feature release |
LTS releases get updates for years, so they suit anything you want to install once and forget. Many older tools still name 17 or 21; you can install several versions side by side.
How do you install Java on Windows?
With winget, the package manager built into Windows 10 and 11. Adoptium's install page gives this command for the latest LTS:
winget install EclipseAdoptium.Temurin.25.JDKFor an older version, change the number, for example EclipseAdoptium.Temurin.11.JDK, which Adoptium also lists.
With the MSI installer. Download the .msi from adoptium.net/temurin/releases and run it. On the Custom Setup screen, Adoptium's guide says adding Java to the PATH is on by default, but Set JAVA_HOME variable is an optional feature you have to switch on. Turn it on if you use build tools such as Maven or Gradle.
For scripted installs, Adoptium gives this silent command, which installs Temurin, updates PATH, associates .jar files and sets JAVA_HOME:
msiexec /i <package>.msi ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome INSTALLDIR="c:\Program Files\Temurin\" /quietOpen a new terminal afterwards, so it picks up the new PATH.
How do you install Java on a Mac?
With Homebrew. On 22 November 2026 Homebrew listed a temurin@25 cask at version 25.0.5.1, a temurin@21 cask, and a plain temurin cask that tracks the newest release, 27.0.1.1. For the LTS:
brew install --cask temurin@25Do not have Homebrew yet? Our guide to installing Homebrew takes a few minutes.
With the .pkg installer. Download the macOS .pkg from Adoptium, open it, accept the licence and click Install. Adoptium says Temurin goes in /Library/Java/JavaVirtualMachines/temurin-<version>.jdk/. For a silent install with admin rights:
sudo installer -pkg <path_to_pkg>/<pkg_name>.pkg -target /Pick the .pkg that matches your Mac: aarch64 for Apple Silicon, x64 for Intel.
How do you install Java on Linux?
On Debian, Ubuntu and Linux Mint, add Adoptium's apt repository, then install the package. These are Adoptium's commands:
sudo apt install -y wget apt-transport-https gpg
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
sudo apt update
sudo apt install temurin-25-jdkOn Linux Mint, Adoptium says to use UBUNTU_CODENAME instead of VERSION_CODENAME in the third line. For Fedora and RHEL, Adoptium documents a yum repository and sudo dnf install temurin-25-jdk; for openSUSE, sudo zypper install temurin-25-jdk after adding its repository; for Alpine, sudo apk add temurin-25-jdk after adding its key and repository.
The repository route means sudo apt upgrade keeps Java patched with the rest of the system.
How do you check the Java install worked?
Open a new terminal and run:
java -versionIt should print a version starting with 25 and name Temurin as the build. If it shows an older version, another Java is earlier on your PATH. On Debian and Ubuntu, sudo update-alternatives --config java lets you choose which installed Java is the default.
How do you set JAVA_HOME?
Some tools look for the JAVA_HOME variable instead of the PATH.
- Windows: tick the JAVA_HOME feature in the MSI installer, or use the silent command above.
- macOS: Apple's
java_hometool finds the folder for you. Add this to~/.zshrc:
export JAVA_HOME=$(/usr/libexec/java_home -v 25)- Linux: point it at the JDK folder that holds
bin/java. This finds it from the activejavaand works in~/.bashrc:
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))Open a new terminal and run echo $JAVA_HOME to check.
How do you switch between Java versions?
Install each version you need, then choose which one runs.
- Windows: the Java that comes first in your PATH wins. Each Temurin MSI with the PATH option adds its own folder, so run
java -versionto see which one is active. Edit the order under Environment Variables in System Properties if you need another, and setJAVA_HOMEto match. - macOS:
/usr/libexec/java_home -Vlists every installed JDK. Change the-v 25in yourJAVA_HOMEline to the version you want and open a new terminal. - Linux: run
sudo update-alternatives --config javaand pick a number from the list.
How do you uninstall Java?
Use the same tool you installed with:
# Windows
winget uninstall EclipseAdoptium.Temurin.25.JDK
# macOS
brew uninstall --cask temurin@25
# Debian, Ubuntu, Mint
sudo apt remove temurin-25-jdkOn Windows you can also remove it from Settings, Apps. Programs that need Java will stop working until you install a version again.
Do you need Java for Minecraft?
Usually not. Fabric's docs say the official Minecraft Launcher ships its own Java, and Mojang's version file for 26.3 names Java 25 as the runtime. You need your own Java in two cases: opening mod or shader installers that come as .jar files, covered in our guide to installing Minecraft mods, and running a server, covered in how to host a Minecraft server yourself. Java 25 from this guide fits both.
Is Oracle Java free?
Partly, and the terms depend on the version and the date. On 22 November 2026, Oracle's download page said JDK 27 and JDK 25 binaries are "free to use in production and free to redistribute, at no cost, under the Oracle No-Fee Terms and Conditions (NFTC)". For JDK 25 it says updates stay under the NFTC until September 2028, after which "Subsequent JDK 25 updates will be licensed under the Java SE OTN License (OTN) and production use beyond the limited free grants of the OTN license will require a fee." JDK 27 gets NFTC updates until March 2027.
Temurin avoids that question. It is built from the same OpenJDK code, and its build scripts are Apache-2.0 on GitHub, where adoptium/temurin-build had 1,182 stars on 22 November 2026.
What is the catch?
Very little for most people. Several Java versions can end up installed, and the one on your PATH may not be the one a program expects, so check java -version first when something fails. Feature releases such as 27 are short-lived, so pick an LTS for anything you will not touch for a while. Uninstalling the MSI or the package removes Java, but environment variables you set by hand stay behind.
Pull it. Stash it.
Questions people ask
Is OpenJDK free to use?
Yes. OpenJDK is the open source reference code for Java, and builds such as Eclipse Temurin are free to download and use, including at work. Oracle's own JDK is a separate download with its own licence terms, which change over a release's life, so read those before using it in production.
Which Java version should I install?
Java 25, unless a program asks for another one. On 22 November 2026, Adoptium listed 8, 11, 17, 21 and 25 as long-term support releases, with 25 the most recent. Java 27 was the newest feature release, but feature releases are replaced every six months. Minecraft 26.3 uses Java 25.
Do I need to install Java to play Minecraft?
Not to play. Fabric's documentation notes the official Minecraft Launcher ships its own Java, and Mojang's version file for 26.3 names Java 25 as the runtime it downloads. You need your own Java to run a Minecraft server, or to open mod and shader installers that come as .jar files.
How do I check if Java is installed?
Open a terminal or Command Prompt and run java -version. It prints the version and the vendor, for example Temurin, if Java is on your PATH. If you get command not found or is not recognized, Java is either missing or not on PATH; reinstall with the PATH option or open a new terminal.
What is the difference between a JDK and a JRE?
The JDK, or Java Development Kit, includes the runtime plus the compiler and developer tools. The JRE is only what you need to run Java programs. Adoptium publishes both, for example temurin-25-jdk and JRE packages on Linux. If you are not sure, install the JDK; it runs everything a JRE does.
Sources
- 1Adoptium: Eclipse Temurin releases (read 2026-11-22)
- 2Adoptium: Installation (read 2026-11-22)
- 3Adoptium: Windows MSI installer (read 2026-11-22)
- 4Adoptium: macOS PKG installer (read 2026-11-22)
- 5Adoptium: Linux RPM, DEB and APK packages (read 2026-11-22)
- 6Adoptium API: available releases (read 2026-11-22)
- 7Homebrew: temurin@25 cask (read 2026-11-22)
- 8Oracle: Java downloads (read 2026-11-22)
- 9adoptium/temurin-build
More repos like this
Get tomorrow's repo in your feed
One free, open source repo a day as a short video, shown working, with the catch named. Pull it. Stash it.
