JDK vs JRE vs JVM in Java
JDK = tools to build (javac, jshell…), JRE = runtime libraries, JVM = the engine that executes bytecode.
javac, and get "command not found". Java is installed... so what's missing?Three nested boxes
The JVM is the engine that executes bytecode. The JRE (Java Runtime Environment) is a JVM plus the standard class libraries: ready-made code for lists, files, math and more. The JDK (Java Development Kit) is a runtime plus developer tools. Engine, car, car plus the workshop that builds cars.
JDK
tools: javac, jshell, javadoc, jar...
JRE
standard libraries
JVM (runs bytecode)The JDK toolbox
javac compiles .java into .class. java launches programs. jshell is an interactive REPL: type a line, see the result. javadoc builds HTML docs. jar packages files. jlink builds custom runtimes. To compile, you need the JDK: a runtime alone has no javac.
Who runs your program?
Your program is running. Which piece is executing its bytecode right now: javac, jar or the JVM?
Think about it, then reveal the answer
The JVM. javac's job ends the moment it has produced the .class files. It takes no part when the program runs.
Not everything is in the JDK
Maven and Gradle are hugely popular build tools, but they're third-party: you install them separately. They call JDK tools like javac for you. javac, jshell, javadoc and jar all ship inside the JDK itself.
Your turn
You want to ship your app with a small runtime that contains only the Java modules it actually uses. Which JDK tool builds that?
javacjlinkjshell
Show the answer
jlink (Java 9+) assembles a custom runtime image from just the modules you list. Smaller download, fewer moving parts.
Where did the JRE go?
Since Java 11, Oracle no longer ships a separate JRE download. Developers install a JDK. Apps that need a runtime build a trimmed one with jlink and bundle it.
In real projects
Production containers often ship a jlink-trimmed runtime instead of a full JDK: smaller images, faster deploys, and no compiler lying around for attackers. Build servers, on the other hand, need the full JDK to compile.
Key takeaways
- JVM: executes bytecode
- JRE: JVM + standard libraries, enough to run programs
- JDK: runtime + development tools, needed to compile
- Since Java 11 Oracle ships no separate JRE; jlink builds custom runtimes
💡 The JVM is a car engine, the JRE is the whole car, and the JDK is the car plus the workshop that builds cars.
There isn't just one JVM. HotSpot (from OpenJDK), Eclipse OpenJ9 and GraalVM are different JVMs, and all of them run the same bytecode.
Practice questions
Which component actually executes your program's bytecode?
- javac
- The jar tool
- The JVM
- javadoc
Check your answer
The JVM. javac only translates source into bytecode; jar packages files; javadoc builds documentation. The JVM loads and executes the bytecode.
Which of these is NOT a tool that ships with the JDK?
- javac
- jshell
- javadoc
- Maven
Check your answer
Maven. Maven is a popular third-party build tool you install separately. javac, jshell and javadoc are all included in the JDK.