JDK, JRE, and JVM

Understand how the JDK, Java runtime images, and JVM fit together, including modern JRE packaging and custom runtimes with jlink.

published: reading time: 18 min read author: Geek Workbench updated: November 20, 2026
Quick Summary

Understand how the JDK, Java runtime images, and JVM fit together, including modern JRE packaging and custom runtimes with jlink.

JDK, JRE, and JVM

JDK, JRE, and JVM describe different parts of Java development and execution. The terms still help explain the platform, but a JRE is not always a separate package you can install. Modern deployments often use a JDK distribution or a custom runtime image.

When to Use

Component Use When
JDK You are writing, compiling, or building Java code
JRE You mean the runtime layer; deployment may use a custom image instead of a separate package
JVM You need to understand bytecode execution or runtime behavior

The Three Layers

This is a conceptual view of the layers. A current JDK distribution does not necessarily contain a separate JRE directory or installer.

flowchart TB
    JDK["JDK distribution"] --> TOOLS["Development tools<br/>javac, javadoc, jdb"]
    JDK --> RUNTIME["Runtime image<br/>(conceptual JRE layer)"]
    RUNTIME --> LIBS["Java platform modules"]
    RUNTIME --> JVM["JVM implementation"]
    JVM --> EXEC["Interpreter and JIT"]
    JVM --> MEM["Memory management"]
  • JVM — The virtual machine specification and its implementations, which execute Java bytecode
  • JRE — A useful name for the JVM and Java platform modules needed to run applications; it is not always a separate package
  • JDK — Development tools plus the Java runtime components used to compile and run applications

JDK (Java Development Kit)

The JDK is a full-featured development environment. It includes everything needed to develop, compile, and debug Java applications.

What’s Inside the JDK

Tool Purpose
javac Java compiler — transforms .java source files to .class bytecode
java Launcher — starts a JVM and runs your application
javap Disassembler — inspects compiled .class files
javadoc Documentation generator — builds HTML API docs from annotations
jar Archiver — packages .class files and resources into .jar files
jdb Debugger — command-line debugging interface
jdeps Dependency analyzer — lists package-level dependencies
jhsdb HotSpot debugger — inspects running JVM internals

JDK Distributions

JDK distributions come from different vendors and can differ in support terms, update cadence, and included tools. OpenJDK is the open-source project behind many distributions. Jakarta EE and Java ME are separate platforms, not editions of the JDK.

JRE (Java Runtime Environment)

The JRE is a useful name for the runtime pieces an application needs: a JVM and the Java platform modules it uses. It is not always offered as a separate download or directory. Oracle’s JDK 11 and later, for example, do not have the old JRE image layout. Deployments can use a vendor-provided runtime or build a custom runtime image with jlink.

What You Get with JRE

The runtime image sits between a compiled application and the operating system. Its main parts are:

  • JVM — The bytecode executor. The java launcher loads your classes from the classpath or module path, and the execution engine (interpreter or JIT compiler) runs the bytecode. The JVM manages memory and Java threads and coordinates garbage collection.
  • Java platform modules — Modules such as java.base provide classes including String, ArrayList, and InputStream. Since Java 9, runtime images use a modular layout rather than the old rt.jar archive.
  • Native libraries — Platform-specific files support operations such as filesystem access and networking.
  • Security configuration — Java security properties configure cryptographic providers and algorithms. The Security Manager policy mechanism is not a current sandbox: the Security Manager is permanently disabled as of JDK 24.

When the java Command Is Missing

Whether a Java command works depends on what executable is installed and on PATH, not on whether a package is named JRE. A JDK distribution includes a java launcher, and a custom runtime image can include one too.

If the shell cannot find a Java launcher, it may report:

$ java MyApp
bash: java: command not found

This means no java executable is available on PATH; it does not tell you whether a JRE package is missing or a runtime is installed elsewhere. If java is found but the class file targets a newer Java release, the launcher can instead report UnsupportedClassVersionError.

For builds, install a JDK distribution with the compiler and build tools you need. For deployment, use a runtime image supplied by your vendor or create one with jlink. The runtime image can omit development tools, but its contents and size depend on the chosen modules and options.

# Typical pattern: build with a JDK, deploy with a runtime image
# Build agent (has JDK)
$ java -version
openjdk version "<installed version>"
$ javac -version
javac 21.0.5

# Production runtime image (contains java, but not javac)
$ java -version
openjdk version "<installed version>"
$ javac -version
bash: javac: command not found

In containers, choose a runtime image that matches the application’s module needs. jlink can assemble a custom runtime image from selected modules; measure the resulting image and startup behavior for your application.

JVM (Java Virtual Machine)

The JVM Specification defines an abstract machine for executing class files. Implementations such as HotSpot and OpenJ9 realize that specification.

JVM Implementation Variants

Runtime or product Provider or distribution Notes
HotSpot VM Oracle JDK and many OpenJDK-based JDKs JVM implementation; GC options vary by build
OpenJ9 VM Eclipse OpenJ9 Separate JVM implementation with its own options
GraalVM Oracle GraalVM distribution JDK distribution with JVM and Native Image tools

The JVM Specification vs Implementation

The Java Language Specification defines the language; the JVM Specification defines class files and execution. It covers:

  • Class file format (bytecode instructions)
  • Abstract runtime data areas
  • Thread synchronization primitives
  • Bytecode instruction set

Implementations vary in performance, garbage collection, and compilation strategy. A compliant implementation must preserve the behavior required by the specification.

Production Failure Scenarios + Mitigations

Wrong JVM Installed for Your JDK Version

Scenario: The runtime image supports an older Java release than the application’s class files require.

Symptoms:

  • UnsupportedClassVersionError at runtime
  • Application crashes on missing methods that exist in newer JDK

Mitigation:

# Check installed Java version
java -version
javac -version

# Set JAVA_HOME to correct JDK path
export JAVA_HOME=/usr/lib/jvm/temurin-17-jdk
export PATH=$JAVA_HOME/bin:$PATH

# In Maven/Gradle projects, enforce JVM version
# maven-compiler-plugin:
#   <release>17</release>

JRE Missing Core Library Classes

Scenario: A custom runtime image omits a Java module the application needs.

Mitigation:

# Verify application dependencies are available
java -cp "lib/*:app.jar" com.example.Main

# List Java platform modules used by the application
jdeps --print-module-deps myapp.jar

# Link a runtime image with the modules it needs
jlink --add-modules java.base,java.logging --output myruntime

JVM Vendor Lock-In

Vendor lock-in usually comes from implementation-specific flags, APIs, or performance assumptions. The JVM Specification leaves garbage collection, compilation, and many runtime options to each implementation. Test the target JVM instead of assuming HotSpot settings will behave the same elsewhere.

JVM flags are a common source of lock-in. For example, -XX:+UseStringDeduplication is a HotSpot option. Some implementations reject unknown flags; others may ignore them, so check the target JVM’s documentation and startup output.

Beyond flags, lock-in creeps in through:

  • Implementation-specific APIs — Internal interfaces such as JVMCI are not portable application APIs. Avoid depending on them unless you also control the runtime.
  • Garbage collector assumptions — Collector names and defaults differ. HotSpot uses G1 by default in most configurations; OpenJ9 provides its own GC policies. Check which collectors the target JVM supports.
  • Startup scripts that parse java -version — Vendor and version output differs. Prefer explicit runtime configuration over string matching.

Scenario: Application assumes HotSpot-specific flags that fail on OpenJ9.

Mitigation:

# Test with target JVM before deployment
# Avoid vendor-specific flags like:
#   -XX:+UseStringDeduplication    # HotSpot only
#   -XX:+UseJVMCICompiler          # HotSpot only

# Use only options documented by the target JVM.
# Heap-size flags such as -Xms and -Xmx are widely supported;
# collector and pause-time flags may be implementation-specific.

Trade-off Table

Decision Advantage Trade-off
Full JDK vs runtime image JDK includes development tools Runtime image can be smaller; contents vary
HotSpot vs OpenJ9 Different GC and startup options Measure the behavior for your application
OpenJDK-based distributions Choice of vendors and support options Licensing and update cadence vary by vendor
GraalVM native image Can start quickly without JVM warmup Longer builds and reflection configuration

Implementation Snippet: Verifying Your Java Environment

import java.util.Properties;

public class JavaEnvironmentCheck {
    public static void main(String[] args) {
        Properties props = System.getProperties();

        System.out.println("=== Java Environment ===");
        System.out.printf("Java Version:    %s%n", props.get("java.version"));
        System.out.printf("JVM Vendor:      %s%n", props.get("java.vendor"));
        System.out.printf("JVM Name:        %s%n", props.get("java.vm.name"));
        System.out.printf("JVM Version:     %s%n", props.get("java.vm.version"));
        System.out.printf("JVM Info:        %s%n", props.get("java.vm.info"));
        System.out.printf("Runtime Name:    %s%n", props.get("java.runtime.name"));
        System.out.printf("Runtime Version: %s%n", props.get("java.runtime.version"));
        System.out.printf("Java Home:        %s%n", props.get("java.home"));
        System.out.printf("Class Path:      %s%n", props.get("java.class.path"));

        // These properties describe the runtime; they do not identify
        // whether a separate JDK or JRE package was installed.
    }
}

Example output from a runtime image:

=== Java Environment ===
Java Version:    17.0.9
JVM Vendor:      Eclipse Adoptium
JVM Name:        OpenJDK 64-Bit Server VM
JVM Version:     17.0.9+9
Runtime Name:    OpenJDK Runtime Environment

Observability Checklist

  • Metrics: JVM vendor, version, and bitness (32/64-bit)
  • Logs: Java startup flags and environment variables on application boot
  • Traces: java -XshowSettings:all -version captures all JVM settings
  • Alerts: Runtime feature version is too old for the application’s class files
  • Health Check: Build with the configured JDK and launch with the intended runtime image

Security and Compliance Notes

Choose a JDK distribution from a vendor you trust, and check its support terms and update cadence. If you build a custom runtime image, rebuild it when you update the JDK it came from. A runtime image is not a substitute for security updates.

Common Pitfalls and Anti-Patterns

Pitfall Why It Hurts Fix
Using a runtime image for development It may not include javac or build tools Install a JDK distribution for builds
Assuming a standalone JRE is available Many current distributions do not provide one Use a vendor runtime or build an image with jlink
Multiple JDK versions without cleanup Builds use the wrong compiler version Use update-alternatives (Linux) or SDKMAN to manage
Assuming JVM vendor neutrality Vendor-specific flags may not be portable Check the target JVM’s documentation
Downloading JDK from untrusted sites Installers may be modified Use a vendor’s official distribution site

Quick Recap Checklist

  • JVM — Specification and implementations for executing Java bytecode
  • JRE — Conceptual runtime layer: a JVM plus the Java platform modules an application needs
  • JDK — Development tools plus runtime components
  • A JRE is not necessarily a separate package; jlink can build a custom runtime image
  • HotSpot, OpenJ9, GraalVM, and Azul Zing are different JVM implementations
  • JDK distributions vary by vendor, support terms, and update cadence
  • Use a JDK for builds; deploy with a vendor runtime or a custom runtime image
  • Check that the runtime supports the Java release targeted by the application
  • Use jlink to create minimal custom runtime images for containerized deployments

Interview Q&A

1. What is the difference between JDK, JRE, and JVM?

The JVM executes Java bytecode. The JRE is a useful name for the JVM and Java platform modules an application needs. The JDK adds tools such as javac, javadoc, and jdb. A JRE is not always a separate installable package; deployments can use a vendor runtime or a custom image.

2. Can a runtime image run Java programs, and what tools might be missing?

A runtime image can launch compiled Java applications if it includes the required modules. It may not include javac, which is a JDK tool. Current JDK distributions often do not contain a separate JRE package, so check what your chosen distribution provides.

3. How do HotSpot, OpenJ9, and GraalVM differ?

HotSpot and OpenJ9 are JVM implementations. GraalVM is a JDK distribution that includes a JVM and Native Image tooling. They offer different runtime and deployment options; compare startup, memory use, and throughput with your application before choosing one.

4. Why do we need the JVM instead of just compiling Java directly to machine code?

The JVM lets the same class files run on different operating systems when a compatible JVM is available. It also provides managed memory, bytecode verification, dynamic class loading, and runtime compilation. These features give implementations room to optimize for their platforms. The Security Manager sandbox is not part of current Java security: it has been permanently disabled since JDK 24.

5. How do you create a minimal Java runtime image for a containerized application?

For a modular application, use jdeps --print-module-deps myapp.jar to list its Java module dependencies. Pass those modules and the application module to jlink --add-modules ... --output myruntime. The output contains the selected modules and their dependencies. Check the image by running its bin/java --list-modules command.

6. Does a JDK include a separate JRE?

Not necessarily. Older JDK layouts included a separate JRE directory, but JDK 11 and later no longer use that layout. A JDK distribution still includes runtime components for running Java programs, and jlink can assemble a separate runtime image for deployment.

7. What is the difference between a JDK and a JRE in terms of file size and use case?

A runtime image contains the JVM and selected Java modules. A JDK distribution also includes development tools such as javac and javadoc. There is no reliable size ratio: vendors package different files, and a jlink image depends on the modules selected. Use the runtime image that fits the deployment and keep it updated.

8. Are Java SE, Jakarta EE, and Java ME JDK editions?

No. Java SE is the platform most JDK distributions implement. Jakarta EE and Java ME are separate platforms with their own specifications and runtimes. They are not editions of a single JDK product.

9. Can you compile Java code with a runtime image?

javac comes with the JDK, not with every runtime image. Install a JDK distribution for compilation and build tasks. A custom runtime image may include java without including javac.

10. What does the JVM specification define, and what does it leave to implementers?

The JVM Specification defines class-file format, bytecode instructions, and abstract runtime data areas. It does not prescribe a particular garbage collector, JIT compiler, memory allocator, or scheduler. Compliant JVMs must follow the specified behavior, while their performance and implementation details can differ.

11. What is the relationship between OpenJDK and Oracle JDK?

OpenJDK is the open-source project used to build Java Development Kits. Oracle JDK, Eclipse Temurin, Amazon Corretto, and Azul Zulu are examples of vendor distributions. Included tools, support terms, and update schedules vary by vendor and release, so check the current terms for the distribution you use.

12. How does jlink create a smaller Java runtime image, and why would you use it?

jlink assembles a runtime image from named modules and their dependencies. For a modular application, use jdeps --print-module-deps myapp.jar to find Java module dependencies, then include those modules and the application module in the jlink command. Image size depends on the modules and options, so measure the result rather than relying on a fixed reduction.

13. How does javac --release affect runtime compatibility?

javac --release 11 compiles against the Java 11 language rules, class-file version, and documented Java 11 APIs. With only -source and -target, code can still accidentally reference APIs added in a newer release. A JVM that is older than the generated class-file version rejects the class with UnsupportedClassVersionError.

14. How can startup and throughput differ between Native Image and a JVM?

Native Image compiles ahead of time, which can reduce startup time and avoid JIT warmup. A JVM can use runtime profiling as the program runs. Throughput depends on the workload, build options, and warmup, so benchmark the deployment you plan to use.

15. What does setting JAVA_HOME do, and what happens if it points to a JRE instead of a JDK?

JAVA_HOME points to a Java installation or runtime image used by tools and scripts. Build tools need access to a JDK compiler; a custom runtime image may not contain javac. The variable alone does not tell you whether a separate JRE package was installed.

16. What is the purpose of the Java bytecode verifier?

The verifier checks class-file structure and bytecode type safety before execution. These checks help the JVM execute bytecode without treating a value as an incompatible type. Verification is not a sandbox or a general permission system; the Security Manager has been permanently disabled since JDK 24.

17. Can a running Java process tell whether it was launched from a JDK or a JRE?

Not reliably from the runtime properties alone. java.home identifies the runtime image in use, and a custom image may omit development tools even if it was built from a JDK. To check for a compiler, inspect the selected installation or run javac --version separately.

18. What is the difference between JDK 8, 11, 17, and 21 LTS releases in practical terms?

Each release adds features and updates the runtime. Java 8 added lambdas and streams; Java 11 standardized the HTTP Client; Java 17 finalized sealed classes; Java 21 finalized record patterns and pattern matching for switch, and added virtual threads. Check each release's notes for compatibility and performance changes rather than assuming an upgrade will improve a workload.

19. What is the classpath, and how does it differ from the module path introduced in Java 9?

The classpath places classes and JARs in the unnamed module. The module path lets the module system resolve named modules and check their declared reads and exports. A JAR without module-info.class can be treated as an automatic module on the module path; on the classpath, it remains in the unnamed module. Modular dependencies also let jlink assemble custom runtime images.

20. Can multiple JDK versions coexist on the same machine, and how do you switch between them?

Yes. Install versions in separate directories and select the intended compiler and runtime with your build tool or a version manager. On Linux, update-alternatives can choose a system default; SDKMAN! can switch versions per shell or project. Check which java and javac commands your build uses, and test against the runtime version you plan to deploy.

Further Reading

Summary

The JDK provides tools for development, the JVM executes bytecode, and the JRE name describes the runtime layer between them. That layer may come from a vendor distribution or a custom image built with jlink; it is not always a separate JRE package. Check the target Java version and modules when preparing an application for deployment.

Next: Java Primitive Types explains the values Java stores before wrappers or objects come into play.

Category

Related Posts

Abstract Classes in Java: Interfaces and Composition

Compare Java interfaces, abstract classes, and composition, then see when shared state, default methods, or sealed types change the design choice.

#java-abstract-classes #java #java-fundamentals

Arithmetic Operators in Java: Division, Overflow, Promotion

Compare Java arithmetic with runnable examples of division, negative remainders, overflow, type promotion, and BigDecimal for decimal money.

#java-arithmetic-operators #java #java-fundamentals

Java Array Basics: Length, Bounds, Copies, and Resizing

Learn Java arrays through runtime-sized allocation, bounds checks, aliasing, copying, and the fixed length that distinguishes them from ArrayList.

#java-array-basics #java #java-fundamentals