← Back to Java

JVM vs JRE vs JDK

JavaEntryjava

The Question

What are the differences between JVM, JRE, and JDK?

What a Strong Answer Covers

  • JVM = runtime engine for bytecode
  • JRE = JVM + libraries
  • JDK = JRE + dev tools
  • JVM is platform-dependent but bytecode is not

Senior-Level Answer

The JVM, JRE, and JDK are nested components of the Java platform, each building on the previous. Understanding their boundaries is essential for knowing what to install in different contexts.

The JVM (Java Virtual Machine) is the runtime engine that executes Java bytecode. It is an abstract specification implemented by vendors (Oracle HotSpot, OpenJ9, GraalVM). The JVM handles bytecode interpretation and JIT (Just-In-Time) compilation to native machine code, memory management and garbage collection, thread scheduling, and security sandboxing. Crucially, the JVM is platform-specific — there is a different JVM binary for Windows, Linux, and macOS — but it presents a uniform interface to Java bytecode, which is platform-neutral.

The JRE (Java Runtime Environment) packages the JVM together with the standard class libraries (java.lang, java.util, java.io, etc.) and supporting files needed to run compiled Java applications. If you only need to run a Java program — not develop one — the JRE is sufficient. Note: since Java 11, Oracle no longer distributes a standalone JRE; the JDK ships with a full runtime, and `jlink` can create minimal custom runtimes.

The JDK (Java Development Kit) is the full developer toolchain. It includes everything in the JRE plus: the Java compiler (`javac`), the archiver (`jar`), documentation generator (`javadoc`), debugger (`jdb`), and other development tools. You need the JDK to compile `.java` source files into `.class` bytecode and to build, package, and debug Java applications.

The relationship: JDK ⊃ JRE ⊃ JVM. In production deployments, you typically install only the JRE (or a JDK, now that they're merged) and ship pre-compiled JARs. On developer machines, you always need the JDK.

Key Differences

AspectJVMJREJDK
PurposeExecute bytecodeRun Java applicationsDevelop and run Java applications
ContainsBytecode interpreter + JIT + GCJVM + standard librariesJRE + compiler + dev tools
Platform-specific?YesYesYes
Includes javac?NoNoYes
Use caseCore runtime engineEnd-user / production runtimeDeveloper machines / CI builds
Standalone since Java 11?Yes (inside JDK)No (merged into JDK)Yes
Who needs itImplicitly used by JREApp deployment serversEvery Java developer

What Separates a 2/3 from a 3/3

2/3 — Passing but Incomplete

Correctly identifies the containment hierarchy (JDK ⊃ JRE ⊃ JVM) and knows that JDK includes the compiler while JRE does not. Distinguishes runtime-only from development contexts.

3/3 — Strong Answer

Explains what the JVM actually does (bytecode execution, JIT, GC), notes that the JVM is platform-specific while bytecode is platform-neutral, and mentions the Java 11 consolidation of JRE into JDK.

Common Mistakes

  • Treating JVM as platform-independent — the JVM itself is a native binary per OS; it's the bytecode that's portable.
  • Not knowing that javac is in the JDK, not the JRE — you cannot compile Java source without the JDK.
  • Claiming JRE is still a separate download in modern Java — since Java 11, Oracle ships only the JDK.
  • Confusing JVM implementations (HotSpot, OpenJ9, GraalVM) as different languages — they all execute standard Java bytecode.

Follow-Up Questions

  • Why is the JVM platform-specific if Java is platform-independent? — Platform independence is for bytecode (.class files), not the JVM itself. The JVM translates platform-neutral bytecode into platform-specific machine instructions.
  • What is JIT compilation and why does it matter for JVM performance? — HotSpot detects frequently executed bytecode (hot paths) and compiles them to native machine code at runtime, eliminating repeated interpretation overhead.
  • What is jlink and how does it relate to the JRE deprecation? — jlink (Java 9+) creates a custom minimal runtime containing only the JDK modules your application uses — replacing the old monolithic JRE for deployment.
  • Name two JVM implementations other than Oracle HotSpot. — OpenJ9 (IBM/Eclipse), GraalVM (Oracle), Azul Zing, Amazon Corretto (distribution, uses HotSpot). Understand they're different implementations of the same spec.

Related Questions

  • Java Platform Independence
  • How JVM Works
  • Main Features of Java
  • public static void main
  • String Constant Pool

Can You Explain This Cold?

Reading the answer is step one. Explaining it unprompted — under interview pressure — is what actually matters. Get AI-graded feedback on your answer with follow-up probes on your weak points.

Get Graded — Free Assessment
GrindQuestionsAITechnical interview assessment
TermsPrivacyAbout