What is the difference between JDK, JRE, and JVM?
PRACTICE TRACK - Java Interview Questions
Hello Learner! 👋
Let's continue your learning journey.
Track your progress and master this topic.
Questions
38 questionsWhat is the Difference Between JDK, JRE, and JVM?
—PROBLEM STATEMENT
Introduction
When you install Java on your machine, you encounter three terms: JVM, JRE, and JDK. These are layered components — each builds on the previous — and understanding them shows interviewers you know how Java actually runs on hardware.
Detailed Answer
JVM (Java Virtual Machine): The engine that executes Java bytecode. It is platform-specific (Windows JVM differs from Linux JVM) but the bytecode it runs is platform-independent. It manages memory (heap/stack), garbage collection, and JIT compilation.
JRE (Java Runtime Environment): JVM + standard class libraries (java.lang, java.util, etc.) + supporting files. Enough to run Java programs but NOT to compile them.
JDK (Java Development Kit): JRE + compiler (javac) + debugger (jdb) + tools like javadoc, jar, javap. Required to develop (write and compile) Java applications.
| Component | Contains | Use Case |
|---|---|---|
| JVM | Bytecode executor, GC, JIT | Runs bytecode |
| JRE | JVM + libraries | Run Java apps (end users) |
| JDK | JRE + javac + tools | Develop Java apps (developers) |
How to Answer in an Interview
JVM is the runtime engine that executes bytecode. JRE bundles the JVM with standard libraries and is enough to run Java apps. JDK includes everything in JRE plus the compiler and development tools — I use it daily to write and build Java applications.
Real-Life Example
Deploying a Java Web App
Think of a restaurant: JVM is the kitchen (where food is cooked/bytecode runs). JRE is the kitchen + all utensils and ingredients (ready to serve). JDK is the kitchen + utensils + the chef’s recipe book and cooking school (development + execution). When deploying to a production server, you only install JRE. When setting up a dev workstation, you install JDK.