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.
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
Why Does This Matter?
Inside the JRE
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
The Compilation Flow
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
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.
How to Set Up Your Environment
Example: Write and Run
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Requires the JDK. Produces Hello.class.
Requires only the JRE. The JVM executes the bytecode.
Example: Distributing Your App
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?
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.
Common Mistakes
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?