AI Hints
Home›Java Tutorial›Installing the JDK, Trying Java in JShell and Your First Program
Java · Lesson 4 of 120

Installing the JDK

Java on your computer.

⏱ 2 min read▶ Video at 4:22🎓 Free
Watch this lesson in the Java courseWatch on YouTube ↗Full Java course

To write and run Java on your own computer, you install the JDK, the Java Development Kit. It's free, and it takes a few minutes.

  • The JDK
  • Free
  • A few minutes

How to install

There are several free builds of the JDK, and they all work the same way. On a Mac, Homebrew is easy. Type brew install openjdk. On Ubuntu Linux, use apt install, with the OpenJDK package. On Windows, download an installer from Adoptium, the free Temurin builds.

SystemHow
macOSbrew install openjdk@17
Ubuntu Linuxsudo apt install openjdk-17-jdk
Windowsinstaller from adoptium.net
Any systeman IDE can download one for you

Check it works

Open a terminal, and type java, space, dash dash version. This asks the JVM for its version. Then javac, dash dash version, checks the compiler. We have Java seventeen, a long term support version. Any version from seventeen, upward, is fine for this course.

Terminal
java --version
openjdk 17.0.18 2026-01-20
OpenJDK Runtime Environment Homebrew (build 17.0.18+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.18+0, mixed mode, sharing)
javac --version
javac 17.0.18

Which version

A new Java version comes out every six months. Some versions get long term support, or LTS, and companies use those for years. This course uses Java seventeen, an LTS version. Everything we learn also works on twenty one, twenty five, and newer.

keyvalue
New versionevery six months
LTSsupported for years
This courseJava 17
Also fine21, 25 and newer

Summary

Install a free JDK, then check it with java dash dash version, and javac dash dash version. Next, a quick way to try Java, called JShell.

Key takeaways
  • Install a JDK
  • java --version
  • Java 17 or newer
Next up: Trying Java in JShell — try code instantly