Install Java

Su Suriya Ravichandran Updated 14 Nov 2026
5 min read ·Lesson 29 of 133

Before writing Java code you need a Java installation on your computer. "Installing Java" involves three decisions (what to install, which version, and from which vendor) and one verification step. This lesson explains those decisions; the next lesson walks through installing the JDK on each operating system.

What to Install: the JDK

Java is distributed as the JDK (Java Development Kit). It contains:

  • javac, the compiler that turns .java source files into .class bytecode
  • java, the launcher that starts the JVM and runs programs
  • jshell, an interactive console for trying out code
  • jar, javadoc, jdeps, and other tools
  • The JVM itself and the complete standard library

For learning and development, always install the JDK. Older guides mention a separate JRE (Java Runtime Environment) for people who only run Java programs. Since Java 11, Oracle and most vendors no longer ship a standalone JRE download; the JDK serves both purposes, and applications that need a minimal runtime build their own with the jlink tool.

Which Version

Java releases a new version every six months (March and September). Every two years one release is designated LTS (Long-Term Support) and receives security updates for several years. Recent LTS versions are 11, 17, 21, and 25.

SituationChoose
Learning Java, starting a new projectThe latest LTS release
Working on an existing projectThe version the project already uses
Experimenting with brand-new language featuresThe latest feature release

This tutorial assumes a current LTS (Java 21 or later). Features such as records, text blocks, switch expressions, pattern matching for switch, and virtual threads are not available in older versions, and examples that use them will not compile on Java 8 or 11.

Code written for an older version almost always runs unchanged on a newer JVM, so installing a recent version costs nothing in compatibility for learning purposes.

Which Vendor

All mainstream Java distributions are built from the same open-source codebase, OpenJDK. They behave identically for writing and running programs. The differences are licensing, support options, and update schedules.

DistributionProviderNotes
Eclipse TemurinEclipse AdoptiumFree for any use; a common default choice
Oracle OpenJDK buildsOracleFree (GPL with Classpath Exception); updated only until the next release
Oracle JDKOracleCheck Oracle's current license terms before commercial use
Amazon CorrettoAmazonFree, long-term updates; used heavily on AWS
Microsoft Build of OpenJDKMicrosoftFree; used in Azure
Azul ZuluAzulFree builds plus paid support
Red Hat build of OpenJDKRed HatCommon on RHEL and Fedora

For learning, Eclipse Temurin (from adoptium.net) or the OS package manager's OpenJDK package is a safe choice. Any of the distributions listed above will work with every example in this tutorial.

Checking Whether Java Is Already Installed

Open a terminal (Command Prompt or PowerShell on Windows, Terminal on macOS and Linux) and run:

java -version
javac -version

Possible results:

Both commands print a version. A JDK is installed and on your PATH:

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

The first line names the version. The exact build numbers and vendor text depend on your installation. If the version is 21 or higher, you are ready.

java works but javac is not found. Only a runtime is installed (or the JDK's bin directory is not on the PATH). Install a full JDK.

Neither command is found ('java' is not recognized... on Windows, command not found on macOS/Linux). Java is not installed or is not on the PATH.

The version is old (for example 1.8.0_..., which is Java 8). Install a newer JDK; multiple versions can coexist.

How the Operating System Finds java

When you type java in a terminal, the operating system searches the directories listed in the PATH environment variable, in order, for a program with that name. Installing a JDK puts its programs in a bin folder, for example:

Windows:  C:\Program Files\Eclipse Adoptium\jdk-25.0.1.8-hotspot\bin
macOS:    /Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home/bin
Linux:    /usr/lib/jvm/java-25-openjdk-amd64/bin

Installers and package managers usually add this folder to the PATH for you. If they do not, the commands are installed but cannot be found by name. The next lesson shows how to set PATH and the related JAVA_HOME variable manually.

Multiple versions

Having several JDKs installed is normal for developers who maintain projects on different versions. The one that runs when you type java is whichever appears first on the PATH. Build tools and IDEs can be pointed at a specific JDK regardless of the PATH. Version managers such as SDKMAN! (macOS/Linux) switch between installed JDKs with one command.

To see which java executable is being used:

# macOS / Linux
which java

# Windows
where java

Installation Methods at a Glance

MethodPlatformsAdvantages
Vendor installer (.msi, .pkg)Windows, macOSGraphical, can set PATH and JAVA_HOME automatically
Package manager (winget, brew, apt, dnf)AllOne command, easy updates
Version manager (SDKMAN!)macOS, Linux, WSLInstall and switch between many versions
Archive (.zip, .tar.gz)AllNo admin rights needed; full manual control
IDE-managed downloadAllIntelliJ IDEA and others can download a JDK from inside the IDE

The next lesson gives step-by-step instructions for these methods.

Verifying a Working Setup

After installing, confirm that the whole cycle of writing, compiling, and running works. Create a file named Check.java:

public class Check {
    public static void main(String[] args) {
        System.out.println("Java version: " + System.getProperty("java.version"));
        System.out.println("Vendor:       " + System.getProperty("java.vendor"));
        System.out.println("Home:         " + System.getProperty("java.home"));
    }
}

Compile and run it:

javac Check.java
java Check

Example output:

Java version: 25.0.1
Vendor:       Eclipse Adoptium
Home:         /usr/lib/jvm/temurin-25-jdk-amd64

System.getProperty reads properties that the JVM sets at startup. java.home shows exactly which installation ran the program, which is the quickest way to resolve confusion when several JDKs are installed. If javac produced Check.class without errors and java printed these lines, the installation is complete.

A single-file program can also be run without a separate compile step:

java Check.java

The launcher compiles the file in memory and runs it, which is convenient for small experiments.

0 Comments

Reviewed before they appear

No comments yet.

Java
Java Introduction Java Features Java Syntax Java Comments Java Statements Java Output Java Variables Java Data Types Java Type Casting Java Operators Java Strings Java Numbers Java Math Java Booleans Java User Input Java Conditions Java If Else Java Switch Java While Loop Java For Loop Java Break Java Continue Java Arrays Java Methods Java Parameters Java Return Values Java Scope Java Recursion Install Java Install JDK Java IDEs Java JDK Java JRE Java JVM Java Compiler Java File Compile Java Run Java JShell Basics Java Packages Java OOP Java Classes Java Objects Class Methods Constructors Constructor Overload this Keyword static Keyword final Keyword Encapsulation Inheritance Polymorphism Abstraction Access Modifiers super Keyword Method Overload Method Override Instanceof Operator Nested Classes Inner Classes Anonymous Classes Enums Records Array Basics Array Length Loop Arrays Multidimensional Arrays Array Copy Array Sorting Array Search ArrayList LinkedList HashSet TreeSet HashMap TreeMap Queue Interface Deque Interface Stack Class Iterator List Interface Set Interface Map Interface Collections Class Comparable Comparator Generics Basics Generic Classes Generic Methods Wildcards String Basics String Length String Methods String Concatenation String Compare String Search String Replace String Split String Format StringBuilder StringBuffer Text Blocks Regular Expressions Number Types Integer Class Float Class Double Class BigInteger BigDecimal Math Class Random Numbers Number Format Date Basics LocalDate LocalTime LocalDateTime ZonedDateTime Date Formatting Date Parsing Period Class Duration Class Java Instant Class Java Exception Basics Java try...catch Java Multiple Catch Blocks Java finally Block Java throw Keyword Java throws Keyword Java Checked Exceptions Java Unchecked Exceptions Java Custom Exceptions Java try-with-resources Java Exception Chaining
Ask about this post
AI Ask about this post

Ask questions about Install Java and get answers drawn from it.

Signed-in readers only.