What is the difference between JDK, JRE and JVM?
BeginnerConceptJava builds (Maven, Gradle, JAR, WAR)
Answer
Short answer
The JVM (Java Virtual Machine) is the engine that runs Java bytecode. The JRE (Java Runtime Environment) is the JVM plus the standard libraries — everything needed to run a Java app. The JDK (Java Development Kit) is the JRE plus development tools like the compiler javac — everything needed to build a Java app.
Explained in simple words
Think of a video game:
- The JVM is the console that actually plays the game.
- The JRE is the console plus its power cable and controllers — enough to play.
- The JDK is all of that plus the tools to make new games.
Why a DevOps engineer cares
| Where | What you need | Example image |
|---|---|---|
| CI build agent / Docker build stage | JDK (to compile) | maven:3.9-eclipse-temurin-21, eclipse-temurin:21-jdk |
| Production container | JRE only (smaller, fewer CVEs) | eclipse-temurin:21-jre |
java -version # is a runtime installed, and which version?
javac -version # is the JDK (compiler) installed?
What to say in the interview
"JVM runs bytecode, JRE is JVM plus libraries for running apps, and JDK adds the compiler and tools for building. In our pipelines we build with a JDK image, and in the final Docker stage we use a JRE image, which is smaller and has a smaller attack surface."
All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: Java apps: Maven, Gradle, JAR & WAR
More on Java builds (Maven, Gradle, JAR, WAR)
What is pom.xml and what is it used for?BeginnerHow do you build and run a Java project with Maven?BeginnerWhat is the difference between a JAR and a WAR file?BeginnerWhat is Gradle and how is it different from Maven?BeginnerHow do you configure a Spring Boot application for different environments?BeginnerA Maven build fails in the pipeline with "Could not resolve dependencies". How do you fix it?Intermediate