What is the difference between JDK, JRE, and JVM?
The JVM is the engine that runs Java bytecode. The JRE is the JVM plus the core libraries needed to run Java programs. The JDK is the JRE plus the tools needed to develop Java programs, such as the compiler. In short, JDK is for building and running, JRE is for running only, and JVM is the part that actually executes the code.
Think of it as layers
- JVM: Java Virtual Machine, runs the compiled bytecode and makes Java portable across systems.
- JRE: Java Runtime Environment, the JVM plus standard libraries, enough to run an app.
- JDK: Java Development Kit, the JRE plus developer tools like javac, the compiler.
The relationship nests neatly. The JDK contains the JRE, and the JRE contains the JVM. If you only want to run a Java app you need the JRE. If you want to write and compile one you need the JDK.
Interviewers like the one line summary: JDK to develop, JRE to run, JVM to execute. Adding that the JDK contains the JRE which contains the JVM shows you understand how they fit together.
Common follow up questions
Related interview questions
Want the full Java guide?
Read every Java concept with notes, diagrams, and code in one place. Track your progress as you go.
Open the Java guide All Java questions