By Shivam Singh, founder of TesterRank · Updated September 2026
JDK (Java Development Kit) is the software you need to write, compile, and run Java programs. It includes the Java compiler (javac), the runtime (java), and all standard libraries. Everything in this learning path — your Java programs, Selenium tests, Maven builds — requires JDK.
| Component | What It Is | Can Compile? | Can Run? |
|---|---|---|---|
| JVM | Java Virtual Machine — executes bytecode | No | Yes |
| JRE | JVM + standard libraries (for users who only run Java apps) | No | Yes |
| JDK | JRE + compiler + dev tools (for developers who write Java code) | Yes | Yes |
You need JDK, not JRE. If you install only JRE, the javac command will not work. Many beginners install JRE by mistake and get "javac is not recognized" — that means you installed the wrong thing.
Install JDK 17 — it is the current Long-Term Support (LTS) version. Companies use LTS versions because they receive security updates for years. JDK 17 is supported until 2029. Almost every Selenium + TestNG tutorial and job uses JDK 17.
Download from Adoptium (Eclipse Temurin) — it is 100% free, open-source, and used by most companies. Go to: https://adoptium.net
Oracle JDK also works but requires a license for commercial use. Adoptium (Temurin) is identical in functionality and completely free. Use Adoptium.
.msi filejava -version
javac -versionYou should see output like:
openjdk version "17.0.x" 2024-xx-xx
OpenJDK Runtime Environment Temurin-17.0.x+x (build 17.0.x+x)
OpenJDK 64-Bit Server VM Temurin-17.0.x+x (build 17.0.x+x, mixed mode)Option A — Homebrew (recommended if you have Homebrew installed):
# Install Homebrew if you don't have it (paste this in Terminal):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install JDK 17:
brew install --cask temurin@17
# Verify:
java -version
javac -versionOption B — Manual download:
java -version and javac -versionNot sure if your Mac is Apple Silicon or Intel? Click the Apple logo (top left) → "About This Mac". If it says "Apple M1/M2/M3/M4" → download aarch64. If it says "Intel" → download x64.
Maven and many tools need a JAVA_HOME environment variable pointing to your JDK installation. The Adoptium installer on Windows usually sets this automatically if you enabled it in step 5. Check if it is set:
# Windows (Command Prompt):
echo %JAVA_HOME%
# Mac/Linux (Terminal):
echo $JAVA_HOMEIf it shows an empty line or "JAVA_HOME is not set", you need to set it manually.
%JAVA_HOME%\binecho %JAVA_HOME%JAVA_HOME tells other tools, like Maven, where Java is installed. These commands find the Java folder and save it in your shell settings.
# Find where Java is installed:
/usr/libexec/java_home
# Add to your shell profile (run this once):
echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> ~/.zshrc
# Reload the profile:
source ~/.zshrc
# Verify:
echo $JAVA_HOME| Error | Cause | Fix |
|---|---|---|
| "java" is not recognized | JDK not installed or not in PATH | Reinstall JDK with PATH option enabled, or add JDK bin folder to PATH manually |
| "javac" is not recognized but "java" works | You installed JRE instead of JDK | Uninstall JRE, install JDK from adoptium.net |
| JAVA_HOME is empty | Environment variable not set | Follow the JAVA_HOME steps above for your OS |
| Wrong Java version shows up | Multiple Java versions installed | Set JAVA_HOME to the correct JDK 17 path and put %JAVA_HOME%\bin first in your PATH |
| Permission denied (Mac) | macOS Gatekeeper blocking | Go to System Preferences → Security & Privacy → click "Open Anyway" |
Run these three commands. If each one prints a version or a folder path, Java is set up correctly.
# All three commands should work:
java -version
javac -version
echo %JAVA_HOME% # Windows
# OR
echo $JAVA_HOME # MacIf all three commands show output without errors, Java is correctly installed. Move to the next lesson.
Exercise 1: Open your terminal and run java -version. Copy the output. Now run javac -version. If both work, Java is ready.
Exercise 2: Run echo %JAVA_HOME% (Windows) or echo $JAVA_HOME (Mac). If it shows the JDK path, your environment is configured correctly.