LearnFrenzy
Sign in Take a free test

Getting Started · Lesson 2 of 42

Install the JDK and Set Up an IDE

4 min read Updated Nov 7, 2026 Saurabh Samir

To write Java you need the JDK and an editor. This lesson gets both working on Windows, macOS or Linux in about fifteen minutes, and shows how to fix the two errors almost everyone hits on the first day.

In this lesson

  • Choose and install a JDK
  • Set JAVA_HOME and PATH
  • Verify with java -version and javac -version
  • Set up IntelliJ IDEA or VS Code, and try JShell

Step 1: Download a JDK

Java is open source, and several organisations publish free builds of the same OpenJDK code. Any of these is fine:

  • Eclipse Temurin (adoptium.net) – the most popular free build. Recommended.
  • Oracle JDK (oracle.com/java) – free to use for development.
  • Amazon Corretto, Microsoft Build of OpenJDK – also free.

Pick JDK 21 (LTS) or a newer LTS, and the installer for your system. On a Mac with an M-series chip choose aarch64 / ARM64; on most Windows laptops choose x64.

Step 2: Install

Windows

  1. Run the .msi installer.
  2. On the "Custom Setup" screen enable Set JAVA_HOME variable and Add to PATH.
  3. Finish and open a new Command Prompt (old windows don't see the new PATH).

macOS

Run the .pkg installer, or use Homebrew:

brew install --cask temurin@21

Linux (Ubuntu / Debian)

sudo apt update
sudo apt install openjdk-21-jdk

Step 3: Verify

java -version
javac -version

Output (your build may differ)

openjdk version "21.0.5" 2024-10-15 LTS
OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS)
javac 21.0.5

If both commands print version 21 or higher, you are ready.

Common mistake: "'javac' is not recognized…"

The JDK's bin folder is not on your PATH. On Windows search for Environment Variables, add a system variable JAVA_HOME = C:\Program Files\Eclipse Adoptium\jdk-21…, then add %JAVA_HOME%\bin to Path. Close and reopen the terminal.

Common mistake: java and javac show different versions

An older Java installed earlier is first on the PATH. Remove the old one (or move the new bin folder to the top of the Path list) so both commands come from the same JDK.

Step 4: Choose an editor

EditorWhy choose it
IntelliJ IDEA CommunityThe professional standard for Java. Excellent auto-complete, refactoring and debugging. Free.
VS Code + "Extension Pack for Java"Lightweight; good if you already use VS Code for other languages.
EclipseStill common in older company projects.

In IntelliJ: New Project → Java → JDK 21 → Create. Right-click the src folder, choose New → Java Class, name it Main, and you have a file ready for the next lesson.

Try code instantly with JShell

The JDK includes JShell, an interactive shell (REPL). Type jshell in a terminal and test single lines without writing a class:

jshell> 24 * 60 * 60
$1 ==> 86400

jshell> "Learn".length() + "Frenzy".length()
$2 ==> 11

jshell> /exit

JShell is perfect for checking how an operator or method behaves before you use it in a program.

How the folders look

A simple Java project

java-course/

  • src/your .java source files (Main.java…)
  • out/ or target/compiled .class files (created by the IDE or build tool)
  • pom.xml / build.gradlelater: Maven or Gradle build file listing libraries

Practice

Try it yourself

  1. Open JShell and calculate how many minutes are in a week.

    Show solution
    jshell> 7 * 24 * 60
    $1 ==> 10080
  2. Find out where your JDK is installed.

    Show solution

    On macOS run /usr/libexec/java_home; on Windows run where java; on Linux run readlink -f $(which java).

Quick check

Which command shows the compiler version?

javac -version

What should JAVA_HOME point to?

The JDK's installation folder (the one that contains bin).

What is JShell?

An interactive shell included with the JDK for running Java snippets without a class or main method.

Summary

  • Install a free JDK 21+ build such as Eclipse Temurin.
  • Make sure java -version and javac -version both work and match.
  • Use IntelliJ IDEA Community (or VS Code) and try ideas quickly in JShell.

Finished this lesson?

Mark it complete to track your progress, then carry on with the next lesson.

Next lesson

Search LearnFrenzy

Esc

Quick links