JDK, JRE and JVM

JVM (Java Virtual Machine)

The JVM is an abstract machine that loads, verifies and executes bytecode. It also manages memory (heap, stack) and performs garbage collection.

JRE (Java Runtime Environment)

JRE = JVM + class libraries. It provides everything needed to run a Java program.

JDK (Java Development Kit)

JDK = JRE + development tools such as javac (compiler), java (launcher), javadoc and jdb (debugger). It's what you need to write and compile programs.

RememberJDK ⊃ JRE ⊃ JVM
JDK — Java Development KitJRE — Java Runtime EnvironmentJVMloads, verifies andexecutes bytecodeClass librariesjava.langjava.utiljava.io …Dev toolsjavacjavajavadocjdbjar
JDK = JRE + development tools; JRE = JVM + class libraries

How a Java Program Runs

  1. You write source code in Main.java.
  2. javac Main.java compiles it to bytecode: Main.class.
  3. java Main starts the JVM, which loads, verifies and executes the bytecode.
Main.java(source code)javacMain.class(bytecode)javaClass loader +bytecode verifierJVM on WindowsJVM on LinuxJVM on macOS
Compile once to bytecode; any operating system with a JVM can run it
Terminal
javac Main.java
java Main
Hello, Java!
Track your progress through the Java course