Learn Java
import com.learnjava.gettingstarted.Install;

Installing the JDK & Setting Up the Environment in Java

@Concept

To write and run Java, you need the JDK (Java Development Kit) — not just a JRE (Java Runtime Environment). The JRE can only run already-compiled programs; the JDK additionally bundles the compiler (javac) and other development tools, so it's what you actually need to build anything. Several free, spec-compliant JDK builds exist — Oracle JDK, Eclipse Temurin, Amazon Corretto, Microsoft Build of OpenJDK — and picking between them is mostly a question of licensing and support preferences, not language behavior, since they all implement the same Java specification.

Once installed, setup is refreshingly small: the installer (or a version manager like SDKMAN) puts java and javac on your system PATH and usually sets a JAVA_HOME environment variable that other tools rely on. There's no separate package manager step or virtual environment to create just to get a basic program running — two working command-line tools is the whole bar to clear.

@HowItWorks
1

Choose a version

LTS releases (17, 21, and so on) are the practical default for stability; newer non-LTS releases add features sooner but drop support faster.

2

Choose a distribution

Oracle JDK, Eclipse Temurin, Amazon Corretto, and Microsoft Build of OpenJDK are all free, spec-compliant builds of the same language — pick based on OS support or a company's licensing policy.

3

Install and set PATH / JAVA_HOME

The installer — or a version manager like SDKMAN — puts java and javac on your PATH and typically sets JAVA_HOME, which build tools and IDEs look for.

4

Verify the install

Running java -version and javac -version in a terminal confirms both the runtime and the compiler are installed and report matching versions.

5

Pick an editor or IDE

A plain text editor works, but an IDE like IntelliJ IDEA or VS Code with its Java extension pack adds inline compiler errors, autocomplete, and one-click run/debug.

@Example
$ java -version
$ javac -version
Output
openjdk version "21.0.3" 2024-04-16
OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9)
OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9, mixed mode)
javac 21.0.3
1java -version asks the installed JVM to report itself — if this fails with "command not found," nothing is on the PATH yet.
2javac -version asks specifically for the compiler's version; on a JRE-only install with no JDK, this command wouldn't exist at all.
3The three java -version lines cover the version string, the runtime build, and the specific VM build — all reporting the same install consistently.
4Both tools report version 21, confirming there's no mismatch between the compiler and the runtime that will execute what it compiles.
@UseCases
Setting up a new laptop or CI build agent before any Java project can compile
Diagnosing a teammate's 'command not found' or version-mismatch error during onboarding
Choosing Eclipse Temurin over Oracle JDK when a company's licensing policy restricts Oracle's terms
Pinning a specific JDK version per project with a tool like SDKMAN or a .tool-versions file

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in Java yourself — building beats watching.