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:
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.
What the JVM does internally:
- ›Class Loader — loads the
.classfile 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.javasource files into.classBytecode) - ›
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.jararchive 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
| JVM | JRE | JDK | |
|---|---|---|---|
| Full name | Java Virtual Machine | Java Runtime Environment | Java Development Kit |
| Purpose | Executes Bytecode | Runs Java programs | Develops Java programs |
| Contains | Execution engine | JVM + Standard Libraries | JRE + Compiler + Dev Tools |
| Who needs it | Part of JRE | End users running Java apps | Developers 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:
In plain English:
- ›You write code in a
.javafile — the JDK's compiler converts it to Bytecode (.class) - ›The JRE provides the standard libraries your code depends on and loads the class into memory
- ›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
- ›JDK — the full toolkit for writing and compiling Java code. Install this.
- ›JRE — the runtime environment for running Java programs. Contains the JVM and standard libraries.
- ›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
| Topic | Link |
|---|---|
| How Java code compiles and runs step by step | How Java Works → |
| Install the JDK and write your first program | Install Java & Setup → |
| Deep dive into JVM internals and architecture | JVM Architecture → |
| What Garbage Collection actually does | Garbage Collection → |
| Stack vs Heap memory in Java | Stack vs Heap → |