JDK, JRE और JVM में अंतर (Diagram Logic के साथ)
JDK = development kit (compiler + JRE), JRE = runtime (libraries + JVM), JVM = bytecode चलाने वाला engine. पूरी comparison table और 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
JDK, JRE और JVM में एक line में अंतर?
JVM bytecode execute करता है, JRE = JVM + programs चलाने की libraries, और JDK = JRE + programs develop करने के compiler और tools.
क्या JVM platform independent है?
नहीं. JVM platform dependent है; platform independent bytecode होता है, और same bytecode चलाने के लिए हर platform का अपना JVM होता है.
क्या सिर्फ JRE से Java program चला सकते हैं?
हां, पहले से compiled .class या .jar file अकेले JRE से चलती है, लेकिन .java source files compile करने के लिए JDK चाहिए क्योंकि javac सिर्फ JDK में है.