Careeroza
JDK vs JRE vs JVM
Three Important Terms
- JVM (Java Virtual Machine): the engine that runs compiled Java code (bytecode). Each operating system has its own JVM.
- JRE (Java Runtime Environment): JVM + the standard class libraries. Enough to run Java programs.
- JDK (Java Development Kit): JRE + development tools such as
javac(compiler),java(launcher),jar,javadoc,jshell. Needed to write and compile Java programs.
How They Fit Together
+---------------------------------------------------+ | JDK (Java Development Kit) | | javac, jar, javadoc, jshell, debugger ... | | +---------------------------------------------+ | | | JRE (Java Runtime Environment) | | | | standard libraries: java.lang, java.util | | | | +---------------------------------------+ | | | | | JVM (Java Virtual Machine) | | | | | | class loader, bytecode verifier, | | | | | | interpreter + JIT compiler, GC | | | | | +---------------------------------------+ | | | +---------------------------------------------+ | +---------------------------------------------------+
Comparison
| JVM | JRE | JDK | |
|---|---|---|---|
| Full form | Java Virtual Machine | Java Runtime Environment | Java Development Kit |
| Job | runs bytecode | provides libraries + JVM to run apps | tools to develop, compile, debug |
| Contains | interpreter, JIT, GC | JVM + libraries | JRE + javac, jar, javadoc... |
| Who needs it | everyone running Java | users of Java apps | developers |
| Platform dependent? | yes (one per OS) | yes | yes |
Note: Java code is platform independent, but the JVM itself is platform dependent. That is exactly why your bytecode runs everywhere: each OS has its own JVM that understands the same bytecode.
Tip: Since Java 11, Oracle no longer ships a separate JRE download. You simply install the JDK.