JDK, JRE, and JVM
Understanding the Java ecosystem components
The Java platform consists of three core components that work together to execute Java programs. Understanding the relationship between JDK, JRE, and JVM is fundamental to Java development.
Java Virtual Machine
An abstract computing machine that enables a computer to run Java programs and provides platform independence by executing bytecode.
Java Runtime Environment
Implementation of JVM along with libraries and files needed to run Java applications.
Includes:
Note: Required to run Java programs, but cannot compile them.
Java Development Kit
Complete development kit for Java developers containing all tools needed to develop, compile, and run Java applications.
Development Tools:
How They Work Together
JDK contains JRE, which in turn contains JVM
To Run Java Programs
Install JRE (includes JVM and libraries)
To Develop Java Programs
Install JDK (includes JRE, JVM, and tools)
Code Examples
Commands to verify Java installation and compile/run programs
1# Check JDK version
2java -version
3
4# Check compiler version
5javac -version
6
7# Compile Java file
8javac HelloWorld.java
9
10# Run compiled class
11java HelloWorldUse Cases
- JVM: Platform-independent execution of Java bytecode
- JRE: Running Java applications on end-user machines
- JDK: Development environment for creating Java applications
Common Mistakes to Avoid
- Installing JRE when JDK is needed for development
- Not setting JAVA_HOME environment variable correctly
- Confusing JVM implementations (HotSpot, OpenJ9, GraalVM)
- Not understanding that .class files contain bytecode, not machine code