01 / 21
▶

JDK vs. JRE

Understand the Java Development Kit and the Java Runtime Environment: what each contains, how they relate, and when you need which one.

Java

What Is Java?

Java is a platform-independent programming language. You write code once, and it runs on any device that has the right software installed. But what exactly is that "right software"? That is where the JDK and JRE come in.

The Big Picture

JDK (Java Development Kit) JRE (Java Runtime Environment) JVM (Java Virtual Machine) Bytecode interpreter Memory management Garbage collector Class Libraries java.lang, java.util java.io, java.net Collections, Streams javac (compiler) jdb (debugger) jar (archiver) javadoc

Why Does This Matter?

Developer?
You need the JDK to write, compile, debug, and package Java applications.
End User?
You only need the JRE to run already-compiled Java programs on your machine.
Server Admin?
Deploy the JRE in production if no compilation is needed; use the JDK if builds happen on-server.

Inside the JRE

JRE JVM Class Loader Bytecode Verifier Execution Engine JIT Compiler Garbage Collector Core Libraries java.lang, java.util java.io, java.math Deployment Tools java (launcher)

The JRE provides everything needed to execute Java bytecode: the JVM interprets your .class files, while the core libraries supply built-in classes like String, ArrayList, and System.

Inside the JDK

1
javac: the compiler that turns .java source files into .class bytecode.
2
jdb: the debugger for stepping through code, setting breakpoints, and inspecting variables.
3
jar: the archiver that bundles compiled classes into a single distributable .jar file.
4
javadoc: generates HTML documentation from specially formatted comments in your source code.
5
The entire JRE: so a developer can also run the programs they build.

The Compilation Flow

Source Code Hello.java javac (compiler) Bytecode Hello.class JVM (executes) JDK only JDK only Portable JRE / JDK Requires JDK Requires JRE (or JDK)

Writing and compiling require the JDK. The resulting .class bytecode is platform-independent and can be executed anywhere there is a JRE.

JDK vs. JRE: Key Distinction

JDK
For building Java applications. Contains the compiler, debugger, archiver, documentation tools, and the entire JRE.
JRE
For running Java applications. Contains the JVM, core libraries, and deployment utilities. No compiler included.

What About the JVM?

The Java Virtual Machine is the innermost layer. It is the engine that actually executes bytecode. The JVM handles memory allocation, garbage collection, and translates bytecode into native machine instructions using the Just-In-Time (JIT) compiler.

JDK JRE JVM Executes .class bytecode on any OS

How to Set Up Your Environment

1
Decide your role: Are you writing Java code (developer) or just running a Java app (user)?
2
Download the right package: Developers install the JDK. End users install the JRE.
3
Set JAVA_HOME: Point the environment variable to your JDK (or JRE) installation directory.
4
Verify: Run java -version (JRE check) and javac -version (JDK check) in your terminal.

Example: Write and Run

// Hello.java (source file)
public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
Step 1: Compile
javac Hello.java
Requires the JDK. Produces Hello.class.
Step 2: Run
java Hello
Requires only the JRE. The JVM executes the bytecode.

Example: Distributing Your App

Developer Machine Has JDK installed Writes + compiles code Outputs: App.jar SEND User A (Windows) Has JRE Runs App.jar ✓ User B (macOS) Has JRE Runs App.jar ✓ User C (Linux) No JRE installed Cannot run ✕ Users need a JRE (or JDK) to run your .jar files.

Example: Diagnosing a Setup Problem

A student types javac Hello.java in the terminal and sees: "'javac' is not recognized as an internal or external command." What happened?

1
Diagnosis: javac is a JDK tool. If the system does not recognize it, the JDK is not installed (or not on the system PATH).
2
Check: Run java -version. If this works, the student has a JRE but not a JDK.
3
Fix: Install the JDK and ensure its bin/ directory is added to the system PATH variable.

Modern Java: JDK-Only Distribution

Starting with Java 11 (2018), Oracle stopped offering a standalone JRE download. Modern Java distributions ship only the JDK. If you download Java today from most providers, you get the full JDK by default.

Before Java 11
JDK and JRE were separate downloads. Users could install the JRE alone.
Java 11+
Only the JDK is distributed. Custom runtimes can be built with jlink.

Common Mistakes

✕ Confusing JDK and JRE
Saying "I installed the JRE" when you need to compile code. The JRE has no compiler.
✕ Thinking JVM Is Separate
The JVM is inside the JRE, not a separate install. You never download "just the JVM."
✕ Ignoring PATH Setup
Installing the JDK but forgetting to add its bin/ folder to PATH. Commands like javac will fail.

Summary Comparison

Feature JDK JRE JVM
Includes Compiler (javac) ✓ ✕ ✕
Includes Debugger (jdb) ✓ ✕ ✕
Includes Core Libraries ✓ ✓ ✕
Includes JVM ✓ ✓ ✓
Can Compile .java Files ✓ ✕ ✕
Can Run .class Files ✓ ✓ ✓
Target User Developers End Users (Internal engine)

Question 1 of 5

Which component is responsible for compiling Java source code into bytecode?

Question 2 of 5

A user has the JRE installed but not the JDK. Which of the following can they do?

Question 3 of 5

Which statement best describes the relationship between JDK, JRE, and JVM?

Question 4 of 5

A developer types javac Main.java and gets "command not recognized." Running java -version works fine. What is the most likely issue?

Question 5 of 5

Starting with Java 11, Oracle changed how Java is distributed. What was the key change?