JVM vs JRE vs JDK — what's the difference, and which do you ship in a Docker image?
Reviewed by Gurusankar M.
Short Answer
JVM runs bytecode. JRE = JVM + core libraries (run only). JDK = JRE + compiler/tools (javac, jar, jstack — to build). For a runtime container ship a JRE (or jlink'd runtime) to keep the image small; build in a JDK stage.
On this page
Concept Made Simple
Coffee Chat Question
“JVM vs JRE vs JDK — what's the difference, and which do you ship in a Docker image?”
Remember It Faster
Mind Map Answer
- JVM
- executes bytecode
- JRE
- JVM + libraries (run apps)
- JDK
- JRE + javac/jar/jstack (build apps)
Think Beyond the Expected
What If?
Why use a multi-stage Docker build with JDK then JRE?
Compile in a JDK stage, then copy only the artifact into a slim JRE (or jlink custom runtime) stage. The final image excludes the compiler/tools — smaller, faster to pull, and a reduced attack surface.
Real World
Right-sizing the base image (JRE/jlink, not full JDK) is a standard container optimization — it can cut image size by hundreds of MB and trim CVEs from unused tooling.
Interviewer's Expectation
Keywords they're listening for:
- JVM executes bytecode
- JRE = run
- JDK = build
- ship JRE/jlink in prod
- multi-stage build
Common Mistakes
- Shipping a full JDK as the runtime image
- Confusing JRE (run) with JDK (build)
- Assuming the JVM and JDK are the same thing
Best Practices
- Multi-stage build: JDK to compile, JRE/jlink to run
- Use a slim, patched base image
- Keep build tools out of the runtime image
Follow-up Questions
- What does jlink do and when would you use it?
- Why did Oracle stop shipping a standalone JRE in newer versions?
- Which JDK tools help you debug production (jstack/jcmd/jmap)?
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: Memory Areas (JVM) Interview question: "JVM vs JRE vs JDK — what's the difference, and which do you ship in a Docker image?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair