JAVA • GETTING STARTED AND TOOLING

JDK vs. JRE — Explain the role of the JDK vs JRE (conceptual)

Understand the two essential Java packages and why developers need one but users need the other.

Historical Context & Motivation

Before Java arrived on the scene, software developers faced a frustrating problem: a program written for one operating system — say Windows — would not run on macOS or Linux without being completely rewritten. In the early 1990s, a team of engineers at Sun Microsystems set out to solve this portability problem. Their creation, the Java programming language, was built on a radical idea: "Write Once, Run Anywhere." To make this vision a reality, Java needed two separate but related toolkits — one for the people who create programs, and one for the people who simply run them.

1991
Project Green Begins
James Gosling and his team at Sun Microsystems began developing a language originally called Oak, designed for embedded devices like TV set-top boxes.
1995
Java 1.0 & the JDK Launches
Sun Microsystems released Java 1.0 along with the first Java Development Kit (JDK), which included a compiler, debugger, and the runtime environment needed to build and run Java applications.
1998
JRE Separated Out
With Java 2 (J2SE 1.2), the Java Runtime Environment (JRE) became a distinct download so that end users could run Java programs without installing developer tools.
2010
Oracle Acquires Sun
Oracle Corporation purchased Sun Microsystems and took over stewardship of the JDK and JRE, continuing to release updates and new versions of both packages.
2020
JRE No Longer Bundled Separately
Starting with Java 11, Oracle stopped providing a standalone JRE download. Developers now use the JDK for everything, though the JRE concept remains at the core of how Java works.

This timeline shows how the JDK and JRE evolved as two sides of the same coin. The central question this lesson addresses is: What exactly does each package contain, and why does the distinction matter when you're learning to program in Java?

Core Principles & Definitions

To understand the JDK versus JRE distinction, you need to grasp how Java programs move from source code to running software. Unlike languages like C++, where code compiles directly into machine instructions for a specific processor, Java uses an intermediate step. Your source code is first compiled into bytecode, a platform-neutral set of instructions. That bytecode is then executed by the Java Virtual Machine (JVM), which translates it into native machine code on whatever operating system you're using. This two-step process is the reason two separate packages exist.

1

JDK — Java Development Kit

The complete toolkit for creating Java programs. It includes the Java compiler (javac), debugging tools, documentation generators, and — importantly — the entire JRE bundled inside.
2

JRE — Java Runtime Environment

The package needed solely to run Java programs. It contains the JVM, core class libraries, and supporting files — but no compiler or developer tools.
3

JVM — Java Virtual Machine

The engine inside the JRE that actually executes bytecode. It handles memory management, garbage collection, and converting bytecode to native instructions for your specific hardware.
4

Bytecode

The intermediate, platform-independent instruction set produced by the Java compiler. Bytecode files end in .class and can run on any device that has a JVM installed.
✦ KEY TAKEAWAY
Think of it like a kitchen versus a dining room. The JDK is the full kitchen — it has ovens, knives, mixers, and everything needed to prepare a meal. The JRE is the dining room — it has plates, forks, and everything needed to consume the meal. The JVM is the table where the eating actually happens. If you're a chef (developer), you need the kitchen. If you're a diner (end user), you only need the dining room.

Visual Explanation — Nesting Diagram

The nesting diagram shows how the JDK (outer violet box) contains the JRE (middle cyan box), which in turn contains the JVM (inner pink box). Developer tools like the compiler sit in the JDK layer outside the JRE.

Notice the layered structure in the diagram above. The JVM is the innermost layer — it is the actual engine that runs your bytecode. Wrapped around it, the JRE adds the standard libraries your program needs, such as java.lang for basic classes like String and Math. Finally, the outermost JDK layer wraps everything in the JRE and adds tools like the javac compiler that converts your .java source files into .class bytecode files.

How Java Code Travels from Source to Execution

Understanding why the JDK and JRE exist as separate entities becomes clear when you trace the journey of a Java program from writing it to watching it run. This is not a mathematical process, but rather a mechanical pipeline with distinct stages, and each stage requires different tools.

This flowchart shows the two-phase lifecycle. The development phase (top) uses JDK tools to compile source code into bytecode. The runtime phase (bottom) uses the JRE to execute that bytecode on any machine.

During the development phase, you write a file called Hello.java. The JDK's javac compiler reads this file and translates it into Hello.class, which contains bytecode. During the runtime phase, the JVM inside the JRE reads that bytecode, verifies it for safety, loads any needed library classes, and executes the program. This is why someone who only wants to run your program never needs the compiler — they only need the runtime environment.

💡 Why Bytecode Matters
Bytecode is the secret ingredient that makes Java portable. Because bytecode is not tied to any specific processor (like Intel x86 or ARM), the same .class file can run on Windows, macOS, Linux, or even a smartphone — as long as a JVM exists for that platform.

Detailed Component Breakdown

What's Inside the JDK?

The JDK is the all-in-one package for Java developers. In addition to containing the entire JRE, it ships with several important tools that you'll encounter as you learn Java. Here is a closer look at each major component.

Key tools included in the JDK
ToolCommandPurpose
Java CompilerjavacConverts .java source files into .class bytecode files.
Java DebuggerjdbLets you step through code line-by-line to find and fix bugs.
Documentation GeneratorjavadocCreates HTML documentation from special comments in your code.
Archive TooljarPackages multiple .class files into a single distributable JAR file.
Interactive ShelljshellLets you type and test small snippets of Java code interactively (added in Java 9).
Java LauncherjavaStarts the JVM and runs a compiled .class file. (Also included in the JRE.)

What's Inside the JRE?

The JRE is a leaner package designed for end users. It contains three main components. First, the JVM itself, which does the actual work of running bytecode. Second, the core class libraries — thousands of pre-built classes organized into packages like java.lang, java.util, java.io, and java.net that provide ready-made functionality for things like string manipulation, file reading, and networking. Third, supporting files such as configuration data and security certificates that the JVM needs at startup.

📌 Modern Note
Since Java 11 (released in 2018), Oracle no longer ships a standalone JRE download. When you install the JDK today, you get everything — including all the JRE components. However, you can still create a custom, minimal runtime image using the jlink tool, which bundles only the modules your application actually needs.

Worked Example — Writing, Compiling, and Running a Program

Let's trace through a complete example so you can see exactly which tools belong to the JDK and which belong to the JRE. We will create a simple "Hello, World!" program and follow each step.

From Source Code to "Hello, World!"
1
Step 1 — Write the Source Code (JDK required)Open a text editor and create a file named Hello.java. Inside, you write: public class Hello { public static void main(String[] args) { System.out.println("Hello, World!"); } } This is plain text — it's human-readable Java source code.
Output: a Hello.java source file on your hard drive.
2
Step 2 — Compile with javac (JDK tool)Open a terminal and run javac Hello.java. The javac compiler is a JDK-only tool. It checks your code for syntax errors, resolves class references, and generates bytecode.
Output: a Hello.class file containing platform-independent bytecode.
3
Step 3 — Launch with java (JRE tool)Now run java Hello in the terminal. The java launcher starts the JVM (part of the JRE). The JVM's class loader reads Hello.class and also loads any standard library classes your program references, such as System and PrintStream.
The JVM executes the main method, and the console prints: Hello, World!
4
Step 4 — Share with a Friend (JRE is enough)If you send the Hello.class file to a friend, they do not need the JDK. They only need a JRE (or a JDK, which includes the JRE) installed on their computer. The bytecode runs identically regardless of whether they're on Windows, macOS, or Linux.
Your friend sees Hello, World! — no recompilation needed.

JDK vs. JRE — Side-by-Side Comparison

Now that you've seen each package in action, let's line them up directly. The table below highlights the key differences and shows where they overlap.

JDK vs. JRE feature comparison
FeatureJDKJRE
Primary purposeDevelop and run Java programsRun Java programs only
Includes JVM?Yes (inside the bundled JRE)Yes
Includes core libraries?YesYes
Includes compiler (javac)?YesNo
Includes debugger (jdb)?YesNo
Includes javadoc?YesNo
Who needs it?Developers writing Java codeEnd users running Java apps
Typical download size~300 MB (varies by version)~60–80 MB (when available)
🔑 REMEMBER THIS RULE
Every JDK includes a JRE, but a JRE does not include the JDK. If you're taking a Java class and writing code, you always install the JDK — you'll never need a separate JRE download because it's already baked in. Think of the JDK as a "superset" that contains everything the JRE has, plus extra tools for building software.

Connecting to Advanced Concepts

Once you're comfortable with the JDK/JRE distinction, several advanced topics build directly on this foundation. Modern Java development has introduced new layers of tooling that extend these core ideas.

From basics to advanced Java tooling
Concept You KnowAdvanced ConceptHow They Connect
JRE runs bytecodeJIT CompilationThe JVM doesn't just interpret bytecode — it identifies "hot" code paths and compiles them to native machine code at runtime for faster performance.
JDK packages apps into JARsBuild Tools (Maven, Gradle)Real-world projects use build automation tools that call JDK commands for you, manage dependencies, and produce deployable packages.
Standalone JRE is deprecatedjlink Custom RuntimesSince Java 9, the modular system lets you build a custom minimal JRE that contains only the modules your app actually uses, reducing size.
JVM is platform-specificGraalVM & Ahead-of-TimeGraalVM can compile Java bytecode directly to native executables, eliminating the need for a JRE on the target machine entirely.

You don't need to master these advanced concepts right now. The key point is that the JDK and JRE model is the foundation upon which all modern Java tooling is built. Understanding why the compiler, runtime, and libraries are separated will help you make sense of build systems, deployment strategies, and performance tuning as you advance in your programming journey.

Practice Problems

PROBLEM 1 — CONCEPTUAL
Your friend wants to play a Java-based game on their laptop. They ask you whether they need to install the JDK or the JRE. Which one do they need, and why?
PROBLEM 2 — BASIC CALCULATION
A student types javac MyApp.java in their terminal and gets the error: 'javac' is not recognized as an internal or external command. They can, however, successfully run java -version. What is the most likely explanation, and how should they fix it?
PROBLEM 3 — INTERMEDIATE
Explain the relationship among JVM, JRE, and JDK using the concept of nesting. If you were drawing a diagram of three concentric rectangles, which would be innermost, which would be in the middle, and which would be outermost? Name at least one component unique to each layer.
PROBLEM 4 — APPLIED
You are part of a school team building a Java application for a science fair kiosk. The kiosk computer has limited storage. You develop the application on your personal laptop and then need to deploy it to the kiosk. Describe what you install on your laptop versus what the kiosk computer needs, and explain why you might use the jlink tool for the kiosk.
PROBLEM 5 — CRITICAL THINKING
Since Java 11, Oracle no longer provides a separate JRE download — you must install the full JDK. Some developers argue this was a good decision, while others disagree. Present one argument in favor and one argument against removing the standalone JRE. Then, explain how the jlink tool addresses the concern raised by the opposing side.

Lesson Summary

The Java Development Kit (JDK) is the complete package for building Java software, containing the javac compiler, debugger, documentation tools, and the entire Java Runtime Environment (JRE). The JRE, in turn, provides everything needed to execute Java programs: the Java Virtual Machine (JVM) and the core class libraries. The layered relationship is JVM ⊂ JRE ⊂ JDK.

Java's two-step process — compiling source code (.java) into platform-independent bytecode (.class), then running that bytecode on any JVM — is the foundation of Java's "Write Once, Run Anywhere" philosophy. As a student learning Java, always install the JDK — it gives you every tool you need to write, compile, debug, and run your programs.

Varsity Tutors • Java • JDK vs. JRE — Explain the role of the JDK vs JRE (conceptual)