In this article Java Environment we give the information about JDK, JVM and JRE in details. Java Development Kit contains tools needed to develop the Java programs, and JRE to run the programs.
Java Environment
Introduction
The Java Environment is a collection of software components required to develop, compile, and run Java programs. The three important components of the Java environment are:
JDK – Java Development Kit
JRE – Java Runtime Environment
JVM – Java Virtual Machine
These components work together to make Java programs development and execution possible.
Basic Relationship
JDK = JRE + Development Tools
JRE = JVM + Java Class Libraries + Supporting Files
JDK > JRE > JVM
JDK – Java Development Kit
Full Form
JDK = Java Development Kit
The JDK is a software development kit used by programmers to develop, compile, debug, test, and run Java applications.
If a programmer wants to create a Java application, the JDK provides the necessary development tools.
Main Components of JDK
The JDK contains:
- JRE
- JVM
- Java Class Libraries/API
- Java compiler
- Java launcher
- Debugging and development tools
- Documentation tools
- Other utilities
Important JDK Commands/Tools
| Tool | Purpose |
| javac | Compiles Java source code |
| java | Launches/runs a Java application |
| javadoc | Generates documentation |
| jar | Creates and manages JAR files |
| jdb | Java debugger |
| javap | Disassembles/class-file analysis tool |
Note: appletviewer was a historical JDK tool associated with Java applets. Java Applet technology has been removed from modern Java releases, so it should not be presented as a current JDK tool.
Example
Suppose we have a Java program:
class Hello {
public static void main(String[] args) {
System.out.println(“Hello World”);
}
}
Save it as:
Hello.java
Compile:
javac Hello.java
This produces:
Hello.class
Run:
java Hello
The JVM loads and executes the compiled bytecode.

JRE – Java Runtime Environment
Full Form
JRE = Java Runtime Environment
JRE provides the environment required to run Java applications.
It contains the JVM and the libraries/supporting files required at runtime.
Basic Structure
JRE = JVM + Java Class Libraries + Supporting Runtime Files
Main Functions of JRE
JRE:
- Provides the runtime environment for Java programs.
- Contains the JVM.
- Provides Java class libraries.
- Provides supporting files required during execution.
- Helps execute Java bytecode.
Important Point
The JRE is primarily associated with running Java applications, whereas the JDK is used for developing Java applications.
JVM – Java Virtual Machine
Full Form
JVM = Java Virtual Machine
The JVM is a virtual machine that provides the runtime environment for executing Java bytecode.
When a Java program is compiled, the Java compiler converts the source code into bytecode stored in a .class file.
The JVM loads and executes this bytecode.
Java Execution Process
Java Source Code
↓
javac
↓
Bytecode (.class)
↓
JVM
↓
Machine/Native Instructions
↓
Output
Example
If we write:
System.out.println(“Hello World”);
the Java compiler converts the source program into bytecode.
The JVM then loads and executes that bytecode on the particular operating system and hardware.
Main Functions of JVM
The JVM performs several important tasks.
Class Loading
The Class Loader loads required .class files into memory.
Bytecode Verification
The JVM verifies bytecode to ensure that it follows Java’s safety and structural rules.
Bytecode Execution
The JVM executes the bytecode using its execution mechanisms, including interpretation and Just-In-Time (JIT) compilation.
Memory Management
The JVM manages memory used by Java programs.
Garbage Collection
The JVM automatically identifies and removes objects that are no longer reachable.
Runtime Environment
The JVM provides the runtime environment required for Java applications.
Major Components of JVM
A simplified JVM architecture includes:
Class Loader Subsystem
It loads Java class files into memory.
Runtime Data Areas
These include areas such as:
- Heap
- Method Area
- Java Virtual Machine Stack
- PC Register
- Native Method Stack
Execution Engine
The execution engine executes bytecode.
It may use:
- Interpreter
- JIT Compiler
- Garbage Collector
Native Method Interface
It allows Java code to interact with native code when required.
Native Method Libraries
These contain libraries required for native method execution.
Why is Java Platform Independent?
One of the major features of Java is platform independence.
The Java source code is compiled into platform-independent bytecode.
The bytecode is executed by a JVM designed for a particular operating system and hardware platform.
For example:
Java Program
↓
Bytecode
↓
JVM
↙ ↓ ↘
Windows Linux macOS
Therefore, the same .class bytecode can generally run on different platforms if an appropriate compatible JVM is available.
This is commonly summarized as:
- Write Once, Run Anywhere (WORA).
- Important Clarification
- Java bytecode is platform-independent, but the JVM implementation is platform-dependent.
Difference Between JDK, JRE and JVM
| Feature | JDK | JRE | JVM |
| Full Form | Java Development Kit | Java Runtime Environment | Java Virtual Machine |
| Main Purpose | Develop Java applications | Run Java applications | Execute Java bytecode |
| Contains JVM | Yes, through its runtime components | Yes | Itself |
| Contains Libraries | Yes | Yes | Uses runtime libraries |
| Compiler | Yes | No | No |
| Developer Tools | Yes | No | No |
| Used by Developers | Yes | Not primarily | Indirectly |
| Executes Bytecode | Through its runtime/JVM | Through JVM | Yes |
Easy Formula
JDK = JRE + Development Tools
JRE = JVM + Runtime Libraries/Supporting Files
Java Compilation and Execution
Consider the following program:
class Demo {
public static void main(String[] args) {
System.out.println(“Welcome to Java”);
}
}
Step 1: Write Source Code
The source file is:
Demo.java
Step 2: Compile
Use:
javac Demo.java
The compiler generates:
Demo.class
Step 3: Bytecode
The .class file contains Java bytecode.
Step 4: Execute
Use:
java Demo
The JVM loads and executes the bytecode.
Step 5: Output
Welcome to Java
Advantages of Java Environment
- Platform Independence: Java bytecode can run on different platforms with suitable JVMs.
- Portability: Java programs can be moved between different systems with minimal changes.
- Automatic Memory Management: The JVM provides automatic memory management and garbage collection.
- Security: Java provides several mechanisms for safer execution, including bytecode verification and runtime checks.
- Robustness: Java provides exception handling, type checking, and automatic memory management.
- Multithreading: Java supports multithreaded programming.
- Rich Libraries: Java provides extensive standard APIs for application development.
FAQ – Frequently Asked Questions
Q1. What is Java Environment?
Answer: Java Environment is the collection of software components required to develop, compile, and execute Java programs. The main components are JDK, JRE, and JVM.
Q2. What is the full form of JDK?
Answer: JDK stands for Java Development Kit.
Q3. What is the full form of JRE?
Answer: JRE stands for Java Runtime Environment.
Q4. What is the full form of JVM?
Answer: JVM stands for Java Virtual Machine.
Q5. What is the main purpose of JDK?
Answer: JDK is used to develop, compile, debug, test, and run Java applications.
Q6. What is the main purpose of JRE?
Answer: JRE provides the environment and runtime components required to run Java applications.
Q7. What is the main function of JVM?
Answer: JVM loads, verifies, and executes Java bytecode.
Q8. Which component contains the Java compiler?
Answer: The JDK contains the Java compiler, javac.
Q9. What is the extension of a Java source file?
Answer: A Java source file generally has the extension:
.java
Q10. What is the extension of a compiled Java class file?
Answer: A compiled Java class file generally has the extension:
.class
Q11. What does javac do?
Answer: javac compiles Java source code into Java bytecode.
Q12. What does the java command do?
Answer: The java command launches a Java application using the JVM.
Q13. What is Java bytecode?
Answer: Java bytecode is the intermediate code generated by the Java compiler. It is stored in .class files and executed by the JVM.
Q14. Why is Java platform independent?
Answer: Java source code is compiled into platform-independent bytecode. This bytecode can run on different platforms using suitable JVM implementations.
Q15. Is JVM platform independent?
Answer: No. The JVM specification is consistent across platforms, but JVM implementations are platform-specific.
Q16. Does JRE contain JVM?
Answer: Yes. JRE includes the JVM along with the runtime libraries and supporting files required to run Java applications.
Q17. Does JDK contain JRE?
Answer: Conceptually, the JDK provides the development environment together with the runtime components needed to run Java programs. Modern JDK distributions package the required runtime components; however, the exact packaging can vary by Java release.
Q18. What is garbage collection?
Answer: Garbage collection is an automatic memory-management process performed by the JVM to reclaim memory occupied by objects that are no longer reachable.
Q19. What is JIT?
Answer: JIT stands for Just-In-Time compiler. It is part of the JVM’s execution system and can compile frequently executed bytecode into native machine instructions at runtime to improve performance.
Q20. Who originally developed Java?
Answer: Java was originally developed at Sun Microsystems, with James Gosling and his team playing key roles in its development.
MCQs on Java Environment
What is the full form of JDK?
A) Java Design Kit
B) Java Development Kit
C) Java Deployment Kit
D) Java Data Kit
Answer: B) Java Development Kit
What is the full form of JRE?
A) Java Runtime Environment
B) Java Running Environment
C) Java Resource Environment
D) Java Runtime Engine
Answer: A) Java Runtime Environment
What is the full form of JVM?
A) Java Virtual Machine
B) Java Visual Machine
C) Java Variable Machine
D) Java Virtual Method
Answer: A) Java Virtual Machine
Which component is primarily used to develop Java programs?
A) JRE
B) JVM
C) JDK
D) JAR
Answer: C) JDK
Which component provides the runtime environment for Java programs?
A) JDK
B) JRE
C) JAR
D) Javadoc
Answer: B) JRE
Which component executes Java bytecode?
A) JDK
B) JRE
C) JVM
D) Java Compiler
Answer: C) JVM
Which tool is used to compile Java source code?
A) java
B) javac
C) javadoc
D) jar
Answer: B) javac
Which command is commonly used to run a Java application?
A) javac
B) java
C) jar
D) jdb
Answer: B) java
What is generated after compiling a Java source file?
A) .exe file
B) .class file
C) .txt file
D) .html file
Answer: B) .class file
Java source files normally have which extension?
A) .class
B) .java
C) .jav
D) .js
Answer: B) .java
Java bytecode is executed by:
A) Compiler
B) JVM
C) Operating System directly
D) Text Editor
Answer: B) JVM
Which of the following is a development tool?
A) javac
B) JVM
C) JRE
D) Bytecode
Answer: A) javac
Which component contains the Java compiler?
A) JVM
B) JRE
C) JDK
D) Operating System
Answer: C) JDK
Java is known for:
A) Platform dependence
B) Platform independence
C) Hardware dependence
D) Operating-system dependence
Answer: B) Platform independence
Java follows which principle?
A) Write Once, Run Anywhere
B) Write Once, Compile Never
C) Run Once, Write Anywhere
D) Compile Once, Delete Anywhere
Answer: A) Write Once, Run Anywhere
Which of the following is responsible for class loading?
A) Class Loader
B) Compiler
C) Text Editor
D) Operating System
Answer: A) Class Loader
Which JVM component executes bytecode?
A) Execution Engine
B) Compiler only
C) Text Editor
D) Source Code Manager
Answer: A) Execution Engine
Which JVM mechanism can improve execution performance by compiling frequently executed code at runtime?
A) JIT Compiler
B) Text Editor
C) Class Loader
D) Javadoc
Answer: A) JIT Compiler
Which JVM process automatically reclaims memory from unreachable objects?
A) Compilation
B) Garbage Collection
C) Class Loading
D) Bytecode Verification
Answer: B) Garbage Collection
Which of the following is NOT a component of the Java development environment?
A) JDK
B) JRE
C) JVM
D) HTML only
Answer: D) HTML only
Which one is the correct relationship?
A) JRE = JDK + JVM
B) JDK = JRE + Development Tools
C) JVM = JDK + JRE
D) JRE = JDK + Compiler
Answer: B) JDK = JRE + Development Tools
Which one is responsible for verifying Java bytecode?
A) JVM
B) Printer
C) Keyboard
D) Monitor
Answer: A) JVM
Java bytecode is stored in:
A) .java file
B) .class file
C) .docx file
D) .exe file
Answer: B) .class file
Which component provides Java runtime libraries?
A) JRE
B) Keyboard
C) Compiler only
D) Monitor
Answer: A) JRE
Which of the following is true?
A) JVM compiles source code directly
B) JDK is used only for displaying output
C) JRE provides runtime support for Java applications
D) JRE is a text editor
Answer: C) JRE provides runtime support for Java applications
Quick Revision
| Term | Remember |
| JDK | Develop Java programs |
| JRE | Run Java programs |
| JVM | Execute Java bytecode |
| javac | Compile .java → .class |
| java | Run Java application |
| .java | Source code |
| .class | Bytecode |
| JIT | Runtime compilation for performance |
| Garbage Collector | Automatic memory management |
| Class Loader | Loads classes |
| Java | Platform-independent through bytecode + JVM |
Easy Memory Trick
JDK → DEVELOP
JRE → RUN
JVM → EXECUTE
JDK develops → JRE provides runtime → JVM executes bytecode.
Some More:
POP- Introduction to Programming Using ‘C’
OOP – Object Oriented Programming
DBMS – Database Management System
RDBMS – Relational Database Management System
Join Now: Data Warehousing and Data Mining