Easy👤 0-2 years👤 3-5 years 1 min read

JVM vs JRE vs JDK — what's the difference, and which do you ship in a Docker image?

Asked inInfosysTCSCognizantAccenture
#jvm#jre#jdk#docker#runtime
Report issue

⚡ 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.

Coffee Chat Question

Concept Made Simple

JVM vs JRE vs JDK — what's the difference, and which do you ship in a Docker image?

🧠Mind Map Answer

Remember It Faster

JVMexecutes bytecode
JREJVM + libraries (run apps)
JDKJRE + javac/jar/jstack (build apps)

🔥What If?

Think Beyond the Expected

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 bytecodeJRE = runJDK = buildship JRE/jlink in prodmulti-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

  • 1What does jlink do and when would you use it?
  • 2Why did Oracle stop shipping a standalone JRE in newer versions?
  • 3Which JDK tools help you debug production (jstack/jcmd/jmap)?

🧩Related Technologies

jlinkDocker multi-stageTemurin/Eclipse Adoptium

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.
Open inChatGPTGeminiClaude

Was this answer helpful?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions