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.
- The JVM runs Java bytecode, the JRE is the JVM plus core libraries, and the JDK is the JRE plus developer tools.
- The JDK contains the JRE, which contains the JVM, so they nest neatly.
- Use the JRE to run Java apps and the JDK to write and compile them.
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.
Frequently asked questions
What is bytecode?
Bytecode is the intermediate form Java source compiles into. The JVM translates it into machine instructions, which is what makes Java portable.
What is the just in time compiler?
The JIT compiler is part of the JVM that converts frequently used bytecode into native machine code at run time to speed up execution.
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