Java Tutorial
🔍

JDK, JRE & JVM

When you start learning Java, three terms come up immediately — JDK, JRE, and JVM.

Most beginners either skip over them or get confused. But understanding what each one does — and how they relate to each other — makes everything else in Java easier to understand.

👉 In one line: JDK is for developers. JRE is for running programs. JVM is the engine that makes Java platform-independent.

🧘 Don't worry if this feels abstract at first.

By the end of this page you'll have a clear mental model. Just focus on the relationship between the three components — everything else follows from that.

The Simple Analogy First

Before any definitions, here's an analogy that makes the relationship click.

Think of building and delivering a package:

  • The JDK is the factory — where you build the package (write and compile Java code)
  • The JRE is the delivery truck — it carries everything needed to deliver the package to any destination
  • The JVM is the engine inside the truck — the actual mechanism that makes it move and run

You need all three to build and run a Java program — but they serve different purposes at different stages.

The Relationship — One Inside the Other

This is the most important thing to understand:

JDK CONTAINS JRE — JRE CONTAINS JVM JDK — Java Development Kit Compiler (javac) · Debugger · Dev Tools · Profiler JRE — Java Runtime Environment Standard Libraries · rt.jar · Supporting Files JVM — Java Virtual Machine Loads · Verifies · Executes Bytecode

The key insight: JDK contains JRE, and JRE contains JVM.

  • If you install the JDK, you get all three automatically
  • If you only install the JRE, you get the JRE and JVM — but not the compiler
  • The JVM alone doesn't exist as a standalone install — it always comes with the JRE

What is the JVM?

JVM = Java Virtual Machine

The JVM is the engine that actually runs your Java program. It takes the Bytecode (the .class file your compiler produces) and translates it into instructions your specific operating system understands.

HOW THE JVM WORKS Bytecode (.class file) ⚙️ JVM Translates & runs Native OS Instructions Windows · Mac · Linux Each OS has its own JVM — but all JVMs understand the same Bytecode This is what makes Java platform-independent

What the JVM does internally:

  • Class Loader — loads the .class file into memory
  • Bytecode Verifier — checks the code is safe to run before executing it
  • Interpreter / JIT Compiler — converts Bytecode into native machine instructions and runs them
  • Garbage Collector — automatically frees memory that is no longer in use

💡 Key point: Every operating system has its own JVM — Windows JVM, Mac JVM, Linux JVM. They all understand the same Bytecode. That's the entire reason Java is platform-independent.

🔗 For a deeper look at JVM internals: → JVM Architecture

What is the JRE?

JRE = Java Runtime Environment

The JRE is everything needed to run a Java program on a machine. It includes:

  • The JVM (to execute the Bytecode)
  • The Java Standard Library — thousands of pre-built classes like ArrayList, String, System, Math
  • Supporting files and configuration that the JVM needs to work

Who needs the JRE? Anyone who wants to run Java programs — but not necessarily write or compile them. For example, if someone downloads your Java application, they need the JRE installed to run it. They don't need the full JDK.

💡 Practical note: Since Java 11, Oracle no longer distributes a standalone JRE installer. The JDK now serves as the standard installation for both developers and end-users. But the concept of JRE still exists as a logical layer inside the JDK.

What is the JDK?

JDK = Java Development Kit

The JDK is the complete package for writing, compiling, and running Java programs. It includes everything in the JRE plus the tools developers need:

  • javac — the Java compiler (converts .java source files into .class Bytecode)
  • java — the launcher that starts the JVM and runs your program
  • javadoc — generates documentation from your code comments
  • jdb — the Java debugger
  • jar — packages compiled classes into .jar archive files
  • jshell — an interactive REPL for trying Java code without writing a full program

Who needs the JDK? Every Java developer. If you are writing Java code, you must install the JDK. It is the starting point for everything.

Side-by-Side Comparison

JVMJREJDK
Full nameJava Virtual MachineJava Runtime EnvironmentJava Development Kit
PurposeExecutes BytecodeRuns Java programsDevelops Java programs
ContainsExecution engineJVM + Standard LibrariesJRE + Compiler + Dev Tools
Who needs itPart of JREEnd users running Java appsDevelopers writing Java code
Standalone install❌ No⚠️ Deprecated since Java 11✅ Yes — install this
Includes compiler❌ No❌ No✅ Yes (javac)

Which One Should You Install?

Always install the JDK.

If you are learning Java or writing Java code, install the JDK. It contains the JRE and JVM inside it — so you get all three in one installation.

Which version?

Install Java 21 LTS (the latest Long-Term Support release). It is free, stable, and widely supported by all major tools and frameworks.

Which distribution?

There are several free JDK distributions. The most commonly used are:

  • Eclipse Temurin (OpenJDK) — recommended for most beginners and professionals
  • Oracle JDK — official Oracle release, free for development use
  • Amazon Corretto — Amazon's OpenJDK build, widely used in cloud environments

🔗 Step-by-step installation: → Install Java & Setup

How They Work Together — The Full Picture

Here is what happens from the moment you write code to the moment it runs:

JDK → JRE → JVM — THE FULL FLOW ① JDK You write HelloWorld.java javac compiles it → HelloWorld.class (Bytecode) ② JRE Provides Standard Libraries System · String · ArrayList Loads class into memory (Class Loader) ③ JVM Interprets Bytecode JIT compiles hot paths → Output on screen "Hello, World!"

In plain English:

  1. You write code in a .java file — the JDK's compiler converts it to Bytecode (.class)
  2. The JRE provides the standard libraries your code depends on and loads the class into memory
  3. The JVM reads the Bytecode and executes it on your machine — producing the output you see

Common Beginner Confusion

"Do I need to install all three separately?"

No. Install the JDK and you get all three. The JDK contains the JRE, which contains the JVM — one installation covers everything.

"What is the difference between JVM and the compiler?"

The compiler (javac) is part of the JDK — it converts your .java source code into Bytecode before the program runs. The JVM runs that Bytecode. They are separate tools doing separate jobs at different stages.

"Is the JVM the same on every computer?"

The JVM is different for each operating system — there's a Windows JVM, a Mac JVM, a Linux JVM. But all of them understand the same Bytecode. That's exactly why your compiled Java program runs on any machine without recompiling.

The 3 Things to Remember From This Page

  1. JDK — the full toolkit for writing and compiling Java code. Install this.
  2. JRE — the runtime environment for running Java programs. Contains the JVM and standard libraries.
  3. JVM — the engine that executes Bytecode and makes Java platform-independent. Each OS has its own JVM.

Summary

  • JVM executes Bytecode — it's the engine that makes Write Once, Run Anywhere possible
  • JRE = JVM + Standard Libraries — everything needed to run a Java program
  • JDK = JRE + Compiler + Dev Tools — everything needed to write and run Java code
  • JDK contains JRE, which contains JVM — they are nested, not separate
  • As a developer, always install the JDK — it gives you all three
  • Use Java 21 LTS with Eclipse Temurin (OpenJDK) for a free, stable, widely-supported setup

What to Read Next

TopicLink
How Java code compiles and runs step by stepHow Java Works →
Install the JDK and write your first programInstall Java & Setup →
Deep dive into JVM internals and architectureJVM Architecture →
What Garbage Collection actually doesGarbage Collection →
Stack vs Heap memory in JavaStack vs Heap →
JDK, JRE & JVM | DevStackFlow