JVM, JRE, and JDK
Understanding the Java ecosystem components and their relationships
Java · beginner · 20 min · 6 steps · free
What you'll learn
- Differentiate between JVM, JRE, and JDK
- Understand the Java compilation process
- Learn about bytecode and platform independence
- Understand the role of each component in Java ecosystem
JavaEcosystem.java
// Understanding JVM, JRE, JDK relationship
public class JavaEcosystem {
public static void main(String[] args) {
System.out.println("Source Code (.java)");
System.out.println("↓ Compiled by JDK");
System.out.println("Bytecode (.class)");
System.out.println("↓ Executed by JVM");
System.out.println("Machine Code");
}
}
Step by step
- Java source code is written in .java files using human-readable syntax.
- JDK (Java Development Kit) contains the compiler (javac) that converts .java files to .class bytecode files.
- JDK (Java Development Kit) contains the compiler (javac) that converts .java files to .class bytecode files.
- Bytecode is platform-independent intermediate code stored in .class files.
- JVM (Java Virtual Machine) interprets bytecode and converts it to platform-specific machine code.
- JRE (Java Runtime Environment) = JVM + Libraries. It's needed to run Java applications.
← Java History and Features · Java Identifiers and Keywords →
More in Java Basics