JDK vs JRE
The JDK is the kit you develop with: a compiler, tools, and a runtime. The JRE is only the runtime, enough to execute an already-compiled program but not to build one.
Detailed Explanation
Think of the difference as build time versus run time. Writing Java requires turning source into class files, which requires a compiler. Running Java requires only a virtual machine and the standard library. The JDK contains both halves. The JRE contains the second half alone.
Concretely, the JDK gives you javac (the compiler), java (the launcher), jar, javadoc, jshell for experimenting, jlink for building trimmed runtimes, and diagnostic tools like jcmd, jstack, jmap, and jfr. The JRE gives you java, the core class library, and the JVM itself. Every JDK includes a runtime, so a JDK can do everything a JRE can.
The split existed for shipping reasons. In the era of desktop Java and browser applets, end users needed to run programs but never compiled anything, and a JRE download was roughly half the size. Oracle therefore published the JRE as a separate consumer product.
That situation has changed, and this is the part most tutorials get wrong. Since Java 11, Oracle and most other vendors no longer ship a standalone JRE at all. Download AdoptOpenJDK/Temurin, Amazon Corretto, or Azul Zulu today and you get a JDK. The replacement for "ship a small runtime" is jlink, which builds a custom runtime image containing only the modules your application actually uses. A service that needs java.base and little else can produce a runtime image well under 50 MB, smaller than the old JRE ever was.
Three terms people mix up are worth separating. A JDK is a development kit. A JRE is a runtime environment. A JVM is the virtual machine inside the runtime that executes bytecode. The JVM is a component, not something you install on its own.
Two more distinctions matter in practice. First, "Java SE" is the specification; a JDK is one vendor's implementation of it. Temurin 21 and Corretto 21 both implement Java SE 21, and your code behaves the same on either. Second, LTS releases (8, 11, 17, 21, 25) get years of security updates, while feature releases get six months. Production almost always tracks an LTS.
You reach for this distinction whenever a build fails on a machine that "has Java". If java -version works but javac -version says command not found, a runtime-only installation is present and no build will work. In Docker, a common mistake is building in a JDK image and then running in the same JDK image, shipping a compiler and diagnostic tools into production for no reason.
The cost of getting it wrong is mostly size and attack surface, not correctness. A full JDK in a container image adds a couple of hundred megabytes and includes tools an attacker would enjoy finding. The cost of going too small is debuggability: strip out the diagnostic tooling and you cannot take a thread dump from a misbehaving production pod.
Code Examples
Compiles with javac (JDK) and runs with java (JDK or JRE).
// Compiles with javac (JDK) and runs with java (JDK or JRE).
public class Hello {
public static void main(String[] args) {
// Vendor and version of the runtime you are actually on.
System.out.println(System.getProperty("java.vendor"));
System.out.println(Runtime.version()); // Java 9+; prints e.g. 21.0.3+9
}
}import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
public class CompilerCheck {
public static void main(String[] args) {
// ToolProvider finds the compiler that ships inside a JDK.
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
// Null means you are on a runtime-only image: no javac present.
System.out.println("Runtime only. Cannot compile here.");
} else {
System.out.println("Full JDK. Compiler available.");
}
}
}Common Gotchas
`javac` not found on a machine with Java installed
the machine has a runtime, not a JDK, or `JAVA_HOME` points at the wrong installation. Build tools read `JAVA_HOME`, so a correct `PATH` alone is not enough.
Standalone JREs are effectively gone after Java 8
guides telling you to "download the JRE" are describing an Oracle product that is no longer published for modern versions. Install a JDK, and use `jlink` if you need a small runtime image.
Multiple JDKs coexist happily
tools like SDKMAN, jEnv, or your build's toolchain configuration let one project compile on 17 and another on 21. Gradle and Maven toolchains pin the version per project instead of relying on whatever `PATH` resolves to.
Compile target is independent of the JDK you build with
a JDK 21 compiler can emit class files for Java 17 using `--release 17`, and doing so also blocks accidental use of newer APIs. Setting only `-source`/`-target` does not check the API surface and produces `NoSuchMethodError` at runtime.