JDK vs JRE vs JVM (JAVA)



This content originally appeared on DEV Community and was authored by Ligouri S Tittus

JVM (Java Virtual Machine)

  1. It is the engine that runs Java programs.
  2. Converts bytecode into machine code (so your OS can understand).
  3. Platform-dependent (Windows JVM ≠ Linux JVM), but bytecode is the same.
  4. Responsible for memory management & garbage collection.

JRE (Java Runtime Environment)

  1. It provides everything needed to run a Java program.
  2. Contains JVM + libraries + classes (but not development tools).
  3. If you only want to run Java apps (not develop them), install JRE.

JDK (Java Development Kit)

  1. It is used by developers to write and run Java code.
  2. Contains JRE + development tools like compiler (javac), debugger, etc.
  3. Needed if you want to develop Java applications.

EXAMPLE

Just by understanding Example:

Imagine Java is like watching and making movies:

JVM → The screen/projector that plays the movie.

JRE → The DVD player + required software to watch movies.

JDK → The camera and editing tools to create the movie.

How it Works:

JDK → For Developers (write & run programs)

JRE → For Users (just run programs)

JVM → For Machines (executes the code)


This content originally appeared on DEV Community and was authored by Ligouri S Tittus