JDK vs JRE
Understand the difference between JDK and JRE, which distributions to use, and how to manage multiple Java versions in enterprise projects.
Last reviewed: January 2025
🔍 What Is It?
JRE — Java Runtime Environment
Contains:
- →JVM (the engine that runs bytecode)
- →Java Class Library (java.lang, java.util, java.io, etc.)
- →Supporting files and configuration
Used by: end users running Java applications, production servers (historically)
JDK — Java Development Kit
Contains everything in JRE plus:
- →
javac— Java compiler - →
javadoc— documentation generator - →
jar— archive tool - →
jdb— Java debugger - →
jshell— interactive REPL (Java 9+) - →
jconsole,jvisualvm— monitoring tools - →
jstack,jmap,jstat— diagnostic tools
Used by: developers, CI/CD pipelines, build servers
JDK Distributions (2025)
- →OpenJDK — open-source reference implementation (free)
- →Eclipse Temurin (Adoptium) — most popular free distribution for production
- →Amazon Corretto — AWS-optimized, free, LTS patches
- →Microsoft Build of OpenJDK — Azure-optimized
- →Oracle JDK — commercial license required for production (Java 17+)
- →GraalVM — includes native image compiler
- →Azul Zulu — certified builds with extended support
🎯 Why Do We Need It?
Understanding JDK vs JRE matters for:
- →Docker images — use JRE-based images for production (smaller), JDK for build stages
- →CI/CD — build agents need JDK; runtime containers need JRE
- →License compliance — Oracle JDK requires a commercial license; use Temurin/Corretto for free
- →Version management — enterprise projects often have multiple Java versions; tools like SDKMAN manage this
🏗️ What Happens in Real Projects?
In a real enterprise Dockerfile (multi-stage build):
# Stage 1: Build with JDK
FROM eclipse-temurin:21-jdk AS builder
WORKDIR /app
COPY . .
RUN ./mvnw package -DskipTests
# Stage 2: Run with JRE (smaller image)
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY --from=builder /app/target/app.jar .
CMD ["java", "-jar", "app.jar"]The JRE image is typically 100–150MB smaller than the JDK image.
⚙️ How It Works
Since Java 11, Oracle stopped shipping a standalone JRE. The JDK is now used everywhere. However, you can create a custom minimal runtime using jlink:
# Create a minimal JRE containing only the modules your app needs
jlink --module-path $JAVA_HOME/jmods \
--add-modules java.base,java.logging,java.sql \
--output my-custom-jreThis produces a runtime as small as 30MB, much smaller than a full JDK.
Version Management with SDKMAN:
sdk install java 21.0.1-tem # Eclipse Temurin 21
sdk install java 17.0.9-tem # Eclipse Temurin 17
sdk use java 17.0.9-tem # switch for current session
sdk default java 21.0.1-tem # set default💻 Example
JDK Tools in Practice — The JDK tools you will use daily as a backend developer.
🤔 Common Confusions
❓ Do I need to install both JDK and JRE?
No. JDK includes everything in JRE. Install only the JDK. Since Java 11, standalone JRE distributions from Oracle no longer exist anyway.
❓ Is Oracle JDK still free?
Oracle JDK is free for development and personal use, but requires a paid subscription for production use (since Java 17). For free production use, use Eclipse Temurin (Adoptium), Amazon Corretto, or Microsoft Build of OpenJDK — all are OpenJDK-based and fully compatible.
🚨 Common Production Issues
Wrong Java version in production — always pin exact versions in Dockerfiles and CI pipelines. Use .java-version or .sdkmanrc files in your repo.
Large Docker images — using JDK in production image adds ~300MB unnecessarily. Use multi-stage builds with JRE for runtime.
License violations — accidentally using Oracle JDK in production without a subscription. Audit your Docker base images.
✅ Best Practices
Use Eclipse Temurin (Adoptium) or Amazon Corretto for free, production-grade JDK distributions.
Pin exact Java versions in Dockerfiles: eclipse-temurin:21.0.1_12-jre, not eclipse-temurin:latest.
Use multi-stage Docker builds: JDK for build stage, JRE for runtime stage.
Use SDKMAN for local version management across multiple projects.
Use LTS versions (8, 11, 17, 21) in production for guaranteed long-term patches.
🏛️ Architect's Note
For new microservices in 2025, use Java 21 LTS with Eclipse Temurin. The virtual threads feature (Project Loom, GA in Java 21) is a game-changer for I/O-bound services — it allows millions of concurrent lightweight threads without the overhead of OS threads, eliminating the need for reactive programming in most cases.
💬 Frequently Asked Questions
🎯 Key Takeaways
🔗 Related Topics
🎯 Practice this topic in interviews
Core Java Interview Prep
Practice interview questions that connect directly to this technology track.
↗ Where this topic fits
Core Java Technology Guide
Return to the Core Java learning hub.
Backend Engineer Career Path
A structured journey through Core Java, Spring Boot, production backend engineering, and interview preparation.
Full Stack Java Developer Career Path
A guided route through frontend foundations, Java backend engineering, delivery workflows, and interview readiness.
Sources
Sources / References
Use these Core Java references to verify the concept in official docs and continue into the most relevant SplashRide pages.
Official documentation
Related SplashRide pages
SplashRide Core Java learning path
Browse the full Core Java topic collection and learning order on SplashRide.
Core Java Interview Prep
Practice Core Java interview questions and scenario-based answers.
Backend Engineer Career Path
A structured journey through Core Java, Spring Boot, production backend engineering, and interview preparation.
Full Stack Java Developer Career Path
A guided route through frontend foundations, Java backend engineering, delivery workflows, and interview readiness.
Java Architecture
Understand how Java is designed to be platform-independent — the Write Once, Run Anywhere principle, and how the JDK, JRE, and JVM fit together.
JVM
Deep dive into the Java Virtual Machine — class loading, memory model, JIT compilation, and how the JVM turns bytecode into running software.