Short answer: on Windows or Windows Server, install Eclipse Temurin, a free OpenJDK build: the MSI from adoptium.net, or winget install --id EclipseAdoptium.Temurin.25.JDK -e. On Ubuntu or Debian, run sudo apt install default-jdk, or name a version such as openjdk-21-jdk. Check with java -version. For anything new, pick an LTS release: Java 25 or 21.
sudo apt update
sudo apt install -y openjdk-21-jdk # or openjdk-25-jdk, or default-jdk
java -versionwinget install --id EclipseAdoptium.Temurin.25.JDK -e
# open a new window, then:
java -versionNothing here was run for this page: it is written on a Debian host without Java. The package versions come from the Ubuntu archive on Launchpad and from packages.debian.org, the Windows details from Adoptium’s installation pages and the winget-pkgs manifests, and the release dates from openjdk.org, all read on 21 October 2026.
Which Java version should I install?
Java ships a feature release every six months, and every two years one of them is a long-term support (LTS) release that gets years of updates. Install an LTS unless a program asks for something else:
| Version | Released | Type | Use it for |
|---|---|---|---|
| Java 25 | 16 September 2025 | LTS (newest) | New projects, Minecraft 26.1 and later |
| Java 21 | September 2023 | LTS | Most current software, Minecraft 1.20.5 to 1.21.x |
| Java 17 | September 2021 | LTS | Older applications and Minecraft 1.18 to 1.20.4 |
| Java 26, 27 | March and 15 September 2026 | Feature releases | Testing new features; updates only until the next release |
The next LTS is planned as Java 29 in September 2027, per Oracle’s roadmap. Two more choices come with every version:
- JDK or JRE. The JRE runs Java programs. The JDK adds the compiler
javacand the developer tools. Developers and build servers need the JDK; a program that only runs, such as a Minecraft server, needs the JRE. - Headless. On Linux,
-headlesspackages leave out the graphical libraries. That is what a server wants: fewer packages, nothing that needs a display.
OpenJDK or Oracle JDK?
OpenJDK builds (your distribution’s openjdk packages, Eclipse Temurin, the Microsoft Build of OpenJDK) are licensed under the GPL version 2 with the Classpath Exception: free for any use, including production. Oracle JDK is Oracle’s own build under Oracle’s terms. As of October 2026, per Oracle’s licensing FAQ and Java blog, Oracle JDK 25 is under the Oracle No-Fee Terms and Conditions, free in production too, with free updates planned until September 2028. Oracle JDK 21 updates from the October 2026 Critical Patch Update onward are under the OTN licence, which is free for personal and development use but needs a paid subscription in production. Unless you want Oracle’s support contract, an OpenJDK build saves you the licence question entirely.
How do I install Java on Ubuntu and Debian?
Every Ubuntu and Debian release has a default-jdk package (and default-jre, default-jre-headless) that points at the version the release considers standard, plus versioned packages next to it:
| Release | default-jdk installs | Also packaged (LTS) |
|---|---|---|
| Ubuntu 26.04 LTS | OpenJDK 25 | 8, 11, 17, 21 |
| Ubuntu 24.04 LTS | OpenJDK 21 | 8, 11, 17, 25 |
| Ubuntu 22.04 LTS | OpenJDK 11 | 8, 17, 21, 25 |
| Debian 13 (trixie) | OpenJDK 21 | 25 |
| Debian 12 (bookworm) | OpenJDK 17 | None: use Temurin for 21 or 25 |
sudo apt update
# a developer machine or build server: the JDK
sudo apt install -y openjdk-21-jdk
# a server that only runs a Java program: the headless runtime
sudo apt install -y openjdk-21-jre-headless
java -version
javac -version # only with a JDKPrefer a versioned package over default-jdk on a server. The default moves when you upgrade the release (Ubuntu 22.04 to 24.04 takes it from 11 to 21), and a program that was happy on one version can refuse the next. java -version prints three lines: the version (openjdk version "21.0.x"), the build of the runtime and the VM. If it prints a version you did not expect, another Java is still the default; see several versions below.
Eclipse Temurin from Adoptium’s repository
Debian 12 packages only Java 17, and some people want the same build on every distribution. Adoptium, the Eclipse project behind Temurin, runs its own apt repository with every LTS version. Its packages are named temurin-VERSION-jdk and temurin-VERSION-jre:
sudo apt install -y curl ca-certificates gpg
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://packages.adoptium.net/artifactory/api/gpg/key/public \
| sudo gpg --dearmor -o /etc/apt/keyrings/adoptium.gpg
echo "deb [signed-by=/etc/apt/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb $(. /etc/os-release && echo $VERSION_CODENAME) main" \
| sudo tee /etc/apt/sources.list.d/adoptium.list
sudo apt update
sudo apt install -y temurin-25-jdkAdoptium’s own instructions put the key in /etc/apt/trusted.gpg.d/; the version above binds it to this one repository with signed-by, which is the safer modern form. If apt update then complains about a missing key, the NO_PUBKEY guide walks through it. On Rocky Linux and AlmaLinux, the distribution packages are called java-21-openjdk-headless (runtime) and java-21-openjdk-devel (JDK); dnf list --available 'java-*-openjdk-headless' shows which versions your point release has.
Several Java versions: update-alternatives
Java versions install side by side under /usr/lib/jvm, and /usr/bin/java is a link managed by the alternatives system. Pick the default like this:
ls /usr/lib/jvm # what is installed
sudo update-alternatives --config java # choose the default java
sudo update-alternatives --config javac # and the compiler, separately--config lists every installed java with a number and marks the current one with *; type a number, or press Enter to keep it. java and javac are separate entries, so after switching one, switch the other too, or javac compiles for a different version than java runs. For a service that must stay on one version whatever the default is, skip the alternatives and call the binary by its full path, such as /usr/lib/jvm/java-21-openjdk-amd64/bin/java. Rocky Linux and AlmaLinux use the same mechanism under the name alternatives.
How do I set JAVA_HOME on Linux?
Build tools such as Maven and Gradle, and some application servers, look for JAVA_HOME. It must name the JDK’s root directory, the one that contains bin, not the java binary itself:
readlink -f "$(command -v java)"
# /usr/lib/jvm/java-21-openjdk-amd64/bin/java -> JAVA_HOME is the part before /bin/java
# for every user, at the next login
echo 'export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64' | sudo tee /etc/profile.d/java-home.sh
# or follow whatever update-alternatives selects
export JAVA_HOME="$(dirname "$(dirname "$(readlink -f "$(command -v java)")")")"Temurin installs to /usr/lib/jvm/temurin-25-jdk-amd64 and similar. A variable set in a profile file reaches login shells only, not systemd services or cron jobs; setting environment variables on Linux covers Environment= for services and the other places it can live.
How do I install Java on Windows and Windows Server?
The same Temurin builds exist for Windows as MSI installers, and they work on Windows 10 and 11 as well as on Windows Server. Two ways to install them:
- 1Download the MSI from adoptium.net
Pick the version (25 or 21), the operating system Windows, the architecture x64 and the package type JDK or JRE, and download the
.msi. - 2Turn on the JAVA_HOME feature during setup
The installer updates
PATHby default, but “Set JAVA_HOME variable” is off unless you select it on the custom setup page. For an unattended install, list the features yourself:cmd or PowerShell (Administrator) msiexec /i TEMURIN-JDK.msi ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome /quietReplace
TEMURIN-JDK.msiwith the file you downloaded.FeatureJavaHomesetsJAVA_HOME,FeatureEnvironmentadds Java toPATH. - 3Check it in a new window
cmd or PowerShell java -version where.exe java echo $env:JAVA_HOME # PowerShell; in cmd: echo %JAVA_HOME%
With winget it is one line: winget install --id EclipseAdoptium.Temurin.25.JDK -e, or EclipseAdoptium.Temurin.21.JDK, and .JRE instead of .JDK for the runtime only; winget search Temurin lists them all. The winget manifest installs the MSI machine-wide with all features, so JAVA_HOME is set too. winget is built into Windows 10, 11 and Server 2025 but not supported on Server 2022 and 2019; winget on Windows Server covers getting it there, or use the MSI.
To set JAVA_HOME by hand, for example after a zip install, use System Properties, Environment Variables, or PowerShell as Administrator. The default Temurin folder is C:\Program Files\Eclipse Adoptium\jdk-VERSION-hotspot:
Get-ChildItem 'C:\Program Files\Eclipse Adoptium' # find the exact folder name
[Environment]::SetEnvironmentVariable('JAVA_HOME', 'C:\Program Files\Eclipse Adoptium\jdk-25.0.4.7-hotspot', 'Machine')Which Java does a Minecraft server need?
The server is where Java has to be installed by hand, and the version must be at least what the game version requires. Mojang’s changelog for 26.1 (released 24 March 2026) moved the requirement to Java 25; the Minecraft Wiki’s server tutorial lists the earlier steps:
| Minecraft Java Edition | Minimum Java | Ubuntu or Debian package |
|---|---|---|
| 26.1 and later | 25 | openjdk-25-jre-headless |
| 1.20.5 to 1.21.x | 21 | openjdk-21-jre-headless |
| 1.18 to 1.20.4 | 17 | openjdk-17-jre-headless |
| 1.17 | 16 | Use 17 |
| 1.12 to 1.16.5 | 8 | Temurin 8 (1.16 also runs on 17) |
A newer Java usually runs an older game version (1.16 runs on Java 17, per the same tutorial), but mod loaders for old versions can be stricter than the game, so follow the loader’s notes there. The complete server setup, with RAM sizing, a systemd service and the firewall, is in making a Minecraft server on a VPS; Forge, NeoForge and Fabric packs are covered in the modded Minecraft server guide.
Common Java install errors
| Message | Cause | Fix |
|---|---|---|
java: command not found | No Java installed | Install a JRE or JDK as above |
'java' is not recognized as an internal or external command | Windows: Java not in PATH, or an old window | Open a new window; reinstall the MSI with the PATH feature |
UnsupportedClassVersionError … class file version 69.0 | Program built for Java 25, older Java running it | Install Java 25 (65.0 is Java 21, 61.0 is Java 17) |
javac: command not found | Only a JRE is installed | Install the JDK: openjdk-21-jdk |
E: Unable to locate package openjdk-25-jdk | Debian 12 does not package it | Use Temurin from Adoptium's repository |
JAVA_HOME is set to an invalid directory | JAVA_HOME names bin or the java binary | Point it at the JDK root, the folder that contains bin |
| java -version shows the wrong version | Another Java comes first | update-alternatives --config java; on Windows where.exe java and fix PATH order |
Java on a VPS or dedicated server
On a server, install the headless JRE of the exact version the program needs, pin it with the full path in the service file, and size the heap with -Xmx below the machine’s RAM so the operating system keeps room. If the whole process grows past the RAM anyway, the kernel ends it without a Java error in the log; the OOM killer guide shows how to confirm that.
A Linux VPS with Ubuntu 24.04 or Debian 13 from the template has Java 21 and 25 one apt install away. For Java software that only runs on Windows, a Windows VPS with Windows Server 2022 or 2019 takes the Temurin MSI the same way a desktop does.
Frequently asked
How do I install Java on Windows?
Download the Eclipse Temurin MSI for Java 25 or 21 from adoptium.net and run it, selecting Set JAVA_HOME variable on the custom setup page, or run winget install --id EclipseAdoptium.Temurin.25.JDK -e. Open a new window and check with java -version. On Windows Server 2022 and 2019, where winget is not supported, use the MSI.
How do I install Java on Ubuntu?
Run sudo apt update, then sudo apt install openjdk-21-jdk or openjdk-25-jdk. default-jdk installs the release's standard version: 21 on Ubuntu 24.04, 25 on 26.04 and 11 on 22.04. A server that only runs a Java program needs just the runtime, for example openjdk-21-jre-headless.
Which Java version does a Minecraft server need?
Minecraft Java Edition 26.1 and later needs Java 25. Versions 1.20.5 to 1.21.x need Java 21, and 1.18 to 1.20.4 need Java 17. Players do not have to install Java, because the launcher bundles its own runtime, but a server needs the right version installed.
Is OpenJDK free for commercial use?
Yes. OpenJDK builds such as Eclipse Temurin and the openjdk packages in Ubuntu and Debian are licensed under the GPL version 2 with the Classpath Exception and are free for any use. Oracle JDK has its own terms: as of October 2026, Oracle JDK 25 is free under Oracle's No-Fee Terms and Conditions, while Oracle JDK 21 updates from the October 2026 patch onward need a paid subscription in production.