How Java Works: JDK, JRE, JVM & JDK Installation
Introduction: How Does Java Work?
Many beginners ask:
“I write Java code, but how does it actually run?”
Java works using a special environment that makes programs run safely on different computers.
This environment is made of three main components:
JDK
JRE
JVM
Understanding these will make Java easy and logical, not confusing.
How Java Works – Step by Step
Java works in three simple steps:
You write Java code
Java converts it into bytecode
Java runs the program on any system
Let’s understand the tools involved.
What Is JVM (Java Virtual Machine)?
Simple Definition
The JVM is a virtual machine that runs Java programs.
What Does JVM Do?
Reads Java bytecode
Converts it into machine code
Executes the program
Why JVM Is Important
Makes Java platform-independent
Ensures security and memory management
JVM is the reason Java works everywhere
What Is JRE (Java Runtime Environment)?
Simple Definition
The JRE provides everything needed to run Java programs.
JRE Includes
JVM
Core Java libraries
When Do You Need JRE?
When you only want to run Java applications
Not used for writing Java code
JRE = Environment to run Java programs
What Is JDK (Java Development Kit)?
Simple Definition
The JDK is used to develop and write Java programs.
JDK Includes
JRE
Java compiler
Development tools
When Do You Need JDK?
When learning Java
When writing and compiling Java code
Every Java learner needs JDK
Relationship Between JDK, JRE, and JVM
Think of them like this:
JVM → Runs Java programs
JRE → Provides the runtime environment
JDK → Provides tools to create Java programs
Hierarchy
JDK → JRE → JVM
Real-Life Analogy
Think of Java like cooking:
Java Code → Recipe
JDK → Kitchen with cooking tools
JRE → Cooking environment
JVM → Chef who cooks the food
Installing Java JDK (Step-by-Step for Beginners)
To start learning Java, you must install the Java Development Kit (JDK).
Step 1: Download Java JDK
Go to the official Oracle Java website
Download the latest Java JDK
Choose the version for your operating system:
Windows
macOS
Linux
Step 2: Install Java JDK
On Windows
Double-click the downloaded installer
Click Next → Install
Wait for installation to complete
On macOS
Open the downloaded
.dmgfileFollow on-screen instructions
On Linux
Use package manager or terminal commands
Install OpenJDK or Oracle JDK
Step 3: Verify Java Installation
Open Command Prompt / Terminal and type:
java -version
If Java is installed correctly, you will see the Java version displayed.
Step 4: Verify Java Compiler
Type:
javac -version
This confirms that JDK is properly installed.
Frequently Asked Questions (FAQs)
Q1. Do I need JDK or JRE to learn Java?
You need JDK to write and practice Java programs.
Q2. Is JVM installed automatically with JDK?
Yes. JDK includes JRE, and JRE includes JVM.
Q3. Can Java work without JVM?
No. JVM is required to run Java programs.
Q4. Which Java version should beginners install?
The latest LTS (Long-Term Support) version is recommended.
Q5. Is Java free to install?
Yes. OpenJDK is free and widely used.