Java · OOP, JVM and backend craft
What is the difference between the JVM, JRE and JDK?
Short answer
The JVM executes bytecode. The JRE bundles the JVM with core libraries, and the JDK adds development tools such as javac, jdb and jlink on top of the JRE.
The JVM is the runtime engine. It loads classes, manages memory, verifies bytecode, interprets and JIT-compiles code, and provides garbage collection. The JRE is the runtime environment: a JVM plus the standard class libraries an application needs to run.
javac Main.java
java Main
jlink --add-modules java.base --output custom-runtimeWhat each layer contains
- JVM: class loader, bytecode verifier, interpreter, JIT, garbage collectors
- JRE: JVM plus core libraries such as java.base, java.sql and java.net
- JDK: JRE plus javac, javadoc, jar, jdb, jlink and monitoring tools
- A server that only runs an application needs a runtime, not the full compiler toolchain
Since Java 9 the JDK is modular and mainstream distributions no longer ship a separate JRE image. You either use the JDK at runtime or generate a smaller custom runtime with jlink. The conceptual distinction still matters when discussing deployment images and container size.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1Which component contains javac?
- 2Why do containers often use a custom runtime image?
- 3Is the JVM a specification or an implementation?
- 4What is the difference between HotSpot and OpenJDK?
Say it in the interview
The JVM is the engine that runs bytecode. The JRE is the JVM plus the standard libraries needed at runtime, and the JDK is the JRE plus development tools like javac and jlink. Since Java 9 there is no separate JRE distribution from most vendors, so I either run on the JDK or build a custom runtime image. For containers I usually use jlink or a smaller base image to reduce size.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Java mock interview and get scored feedback on depth, clarity and confidence.