Difference Between JDK, JRE and JVM (With Diagram Logic)
JDK = development kit (compiler + JRE), JRE = runtime (libraries + JVM), JVM = the engine that runs bytecode. Full comparison table and interview answers.
The one-line answer
JDK ⊃ JRE ⊃ JVM — each one contains the next.JVM — Java Virtual Machine
The engine that actually executes Java bytecode (.class files). It converts bytecode to machine code for the current operating system. This is why Java is "write once, run anywhere" — the .class file is the same everywhere, only the JVM differs per platform.
MyProgram.java --(javac)--> MyProgram.class --(JVM)--> machine code
JVM also handles memory management and garbage collection.
JRE — Java Runtime Environment
JRE = JVM + core libraries (java.lang, java.util, collections, IO...). If you only want to run a Java application, JRE is enough. It contains no compiler — you cannot write/compile programs with JRE alone.
JDK — Java Development Kit
JDK = JRE + development tools: javac (compiler), java (launcher), jar, javadoc, debugger. Developers install JDK; end users historically needed only JRE.
JDK = JRE + javac, jar, javadoc, debugger
JRE = JVM + core libraries
JVM = the bytecode execution engine
Comparison table
| Point | JDK | JRE | JVM |
|---|---|---|---|
| Full form | Java Development Kit | Java Runtime Environment | Java Virtual Machine |
| Purpose | Develop + run | Run only | Execute bytecode |
| Contains | JRE + dev tools | JVM + libraries | Execution engine |
| Compiler (javac) | ✅ Yes | ❌ No | ❌ No |
| Who installs | Developers | End users | Comes inside JRE |
| Platform dependent? | Yes | Yes | Yes (but bytecode is not) |
Interview follow-up: Is JVM platform independent?
One-line answer
JDK ⊃ JRE ⊃ JVM — हर एक अगले को contain करता है.JVM — Java Virtual Machine
वह engine जो Java bytecode (.class files) को actually execute करता है. यह bytecode को current operating system के machine code में बदलता है. इसीलिए Java "write once, run anywhere" है — .class file हर जगह same है, सिर्फ JVM हर platform पर अलग है.
MyProgram.java --(javac)--> MyProgram.class --(JVM)--> machine code
JVM memory management और garbage collection भी handle करता है.
JRE — Java Runtime Environment
JRE = JVM + core libraries (java.lang, java.util, collections, IO...). अगर आपको Java application सिर्फ चलानी है, तो JRE काफी है. इसमें compiler नहीं है — अकेले JRE से program लिख/compile नहीं कर सकते.
JDK — Java Development Kit
JDK = JRE + development tools: javac (compiler), java (launcher), jar, javadoc, debugger. Developers JDK install करते हैं; end users को historically सिर्फ JRE चाहिए होता था.
JDK = JRE + javac, jar, javadoc, debugger
JRE = JVM + core libraries
JVM = bytecode execution engine
Comparison table
| Point | JDK | JRE | JVM |
|---|---|---|---|
| Full form | Java Development Kit | Java Runtime Environment | Java Virtual Machine |
| Purpose | Develop + run | सिर्फ run | Bytecode execute |
| Contains | JRE + dev tools | JVM + libraries | Execution engine |
| Compiler (javac) | ✅ हां | ❌ नहीं | ❌ नहीं |
| कौन install करता है | Developers | End users | JRE के अंदर आता है |
| Platform dependent? | हां | हां | हां (लेकिन bytecode नहीं) |
Interview follow-up: क्या JVM platform independent है?
Frequently Asked Questions
What is the difference between JDK, JRE and JVM in one line?
JVM executes bytecode, JRE = JVM + libraries needed to run programs, and JDK = JRE + compiler and tools needed to develop programs.
Is JVM platform independent?
No. The JVM is platform dependent; it is the bytecode that is platform independent, and each platform has its own JVM to run the same bytecode.
Can we run a Java program with only JRE?
Yes, an already-compiled .class or .jar file runs with JRE alone, but compiling .java source files requires the JDK because javac is only in the JDK.