Installing Java trips up a lot of beginners. Not because it is hard, but because you have to make a few choices before you even start, and the official pages do not always explain what those choices mean.
This guide walks through every step. By the end, you will have Java working on your machine and understand why you picked the version you did.
JDK, JRE, JVM: What is the difference?
Three acronyms that confuse everyone at first. Here is the short version.
JVM (Java Virtual Machine) runs your compiled Java code. It is the engine.
JRE (Java Runtime Environment) includes the JVM plus the libraries needed to run Java applications. If you only want to run Java programs, the JRE is enough.
JDK (Java Development Kit) includes the JRE plus the compiler (javac) and other tools you need to write and build Java programs.
One thing that trips people up: since Java 11, the JRE is no longer distributed separately. You just download the JDK, which includes everything. So for development, the JDK is what you want.
Which version should you install?
Java releases a new version every six months. Most of them are short-lived. The ones that matter are called LTS (Long Term Support) releases. They get security updates for years.
Here is where things stand as of mid-2026:
- Java 25 is the latest LTS, released September 2025. It gets updates until at least 2028. This is what I recommend for new projects.
- Java 21 is the previous LTS. Still widely used, especially in enterprise environments. Gets free updates until late 2026.
- Java 26 is the current non-LTS release. Fine for experimenting, but it stops getting updates in six months when Java 27 arrives.
If you are learning Java, go with Java 25. If your company or university specifies Java 21 or even Java 17, use that. The basics of the language are the same across all of them.
Which distribution? (This matters more than you think)
"Java" is a specification. Anyone can build a JDK from the open-source OpenJDK source code. Several organizations do, and they all produce compatible binaries. Here are the main ones:
Eclipse Temurin (from Adoptium) — My recommendation for most people. Free, open source, no usage restrictions. Backed by Microsoft, Red Hat, and others. Download it from adoptium.net.
Oracle JDK — The "official" one from Oracle. Free for production use under the NFTC license for Java 21 and 25, but Oracle has changed licensing terms before and may do so again. I would not rely on it for commercial projects without reading the fine print.
Amazon Corretto — Amazon's build of OpenJDK. Free, long-term support, no surprises. Popular in AWS environments.
Azul Zulu, IBM Semeru, Microsoft Build of OpenJDK — All solid, all free, all based on the same OpenJDK source. The differences are mostly about which company provides support.
For a beginner, the choice barely matters. I use Eclipse Temurin because it is free with no strings attached and works on every operating system. The rest of this guide assumes you are using it, but the steps are nearly identical regardless of which distribution you pick.
Installing on Windows
- Go to adoptium.net
- The site auto-detects your OS. Pick JDK 25 (LTS) from the version dropdown
- Click the download button. You get an
.msiinstaller - Run the installer. Leave the defaults checked, including "Set JAVA_HOME variable" and "Add to PATH"
- Click through to finish
The installer handles environment variables for you, which is the part most people get wrong doing it manually.
Installing on macOS
The easiest way is through Homebrew:
brew install --cask temurin@25
If you do not have Homebrew installed yet, run this first:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Homebrew sets up JAVA_HOME for you. If you prefer a graphical installer, download the .pkg file from adoptium.net and double-click it.
Installing on Linux
On Ubuntu or Debian-based systems:
# Add the Adoptium repository
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo apt-key add -
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
# Install
sudo apt update
sudo apt install temurin-25-jdk
On Fedora or RHEL-based systems:
sudo dnf install temurin-25-jdk
The package manager handles PATH and JAVA_HOME configuration automatically.
Setting JAVA_HOME manually (if needed)
Sometimes the installer does not set things up correctly, or you installed from a tar.gz archive. Here is how to fix it.
On Windows, search for "Environment Variables" in the Start menu. Add a new system variable called JAVA_HOME pointing to your JDK installation folder, something like C:\Program Files\Eclipse Adoptium\jdk-25.x.x. Then edit the PATH variable and add %JAVA_HOME%\bin.
On macOS or Linux, add these lines to your ~/.zshrc or ~/.bashrc:
export JAVA_HOME=/path/to/your/jdk
export PATH=$JAVA_HOME/bin:$PATH
Then reload the file:
source ~/.zshrc # or ~/.bashrc
Verify the installation
Open a terminal or command prompt and run:
java -version
You should see something like:
openjdk version "25.0.3" 2026-04-15
OpenJDK Runtime Environment Temurin-25.0.3+7 (build 25.0.3+7)
OpenJDK 64-Bit Server VM Temurin-25.0.3+7 (build 25.0.3+7, mixed mode)
Then check the compiler:
javac -version
If both commands return the version number without errors, you are done. Java is installed and ready.
Common problems
"java is not recognized as an internal or external command" (Windows) — Your PATH variable is not set correctly. Go back to the Environment Variables settings and make sure %JAVA_HOME%\bin is in the PATH.
Wrong version showing up — You might have an older JDK installed that takes priority. Run which java (macOS/Linux) or where java (Windows) to see which binary is being found first. Remove the old one or reorder your PATH.
Permission denied on Linux — Make sure you ran the install commands with sudo.
macOS says "developer cannot be verified" — Go to System Settings > Privacy & Security and click "Allow Anyway." This is a standard macOS Gatekeeper warning for installers not from the App Store.
Quick summary
- The JDK is everything you need to write and run Java. Skip the JRE.
- Pick an LTS version. Java 25 is the current one.
- Use Eclipse Temurin from Adoptium unless you have a specific reason not to.
- The installer handles environment variables on Windows. On macOS and Linux, package managers do the same.
- Run
java -versionandjavac -versionto verify everything works. - If commands are not found, your PATH or JAVA_HOME needs fixing.
Based on dev.java/download and Oracle JDK installation guides.
Top comments (0)