
How JVM Works Internally - JVM Architecture
This article breaks down the key components of the Java Virtual Machine (JVM), including Class Loader, Memory Management, and Execution Engine, to help you understand how Java applications run efficiently across platforms.

Shreya Adak
February 14, 2025
5 min read
What is JVM?#
A Virtual Machine (VM) is an emulation (software-based), used as an entire physical computer to execute multiple operating systems or that provides an environment where a single application runs independently.
Java Virtual Machine (JVM) is a process virtual machine. It provides a runtime environment (Java Runtime Environment) to execute the byte code of a single application independently.
JVM is a runtime engine. Java’s Write Once Run Anywhere (WORA) behavior is enabled by using JRE, Java Runtime Environment is a core component of JVM for executing the java byte code.
At the time of compilation, the source code (.java files) converts to the Java byte code with the use of the javac compiler.
JVM is responsible for making Java Platform-Independent, Secure, High-performance, and Robust.
What is JVM Architecture :#
The Java byte code is processed to execute with the help of multiple stages of execution of JVM. These stages define all the overall functionality of JVM. Here, we have explained the whole of the internal works of JVM.

JVM Component:#
- Class Loader Subsystem: Class Loader is responsible for dynamically loading java class files (.class file) in memory according to requirements. ****After compilation of Java source code or human readable/understandable code which is a .java file is converted to the .class file. This class file contains JVM readable byte code.
- Loading: After reading the class files the class loader generates the binary data. For each class file, JVM stores the required information inside the memory area.
- Bootstrap Class Loader: Loads all the core java classes (e.g. java.util., java.lang., etc.).
- Extension Class Loader: Loads ***all extra libraries (e.g. javax.swing.).
- System/Application Class Loader: Loads your main applications from class-path (e.g. your projects).
- Linking: After loading the classes inside memory, these go through the linking process to confirm each class is correctly prepared for execution by JVM.
- Verification: Check whether each class file follows Java rules properly or not. If not then JVM throws error(e.g. verify error).
- Preparation: Check that memory is allocated for static variables and set their default values(e.g. ‘0’ or ‘null’).
- Resolution: Replace symbolic reference (e.g. java.lang.String) with actual memory address (e.g. actual String class).
- Initialization: Only when classes are used the first time, at that time all the final values to static fields, blocks are initialized. These all happen once objects are created.
- Loading: After reading the class files the class loader generates the binary data. For each class file, JVM stores the required information inside the memory area.
- Memory Area (Memory Management) : Ensures that objects are created, used, and removed (By Garbage Collector) properly.
- Method Areas: Stores all types of class-level information (e.g. class name, methods, etc.).
- Heap Areas: Holds all object information.
- Stack Areas: Stores all method calls.
- PC Registers: Tracks every time current instructions of each thread.
- Native Method Areas: Runs all the methods that are written by other languages (e.g. C, C++)
- Execution Area : Helps to execute the java byte code to native machine code.
- Interpreter: Reads java byte code (.class files) line by line.
- JIT Compiler: JIT stands for Just In Time. It converts java byte code to native machine code during runtime.
- Intermediate Code Generator: Converts bytecode into a simplified intermediate form.
- Optimizer: Improves performance by optimizing the intermediate code.
- Target Code Generator: Converts the optimized code into native machine code.
- Profiler: Analyzes program’s behavior and performance.
- Garbage Collector: Optimized free up memory by removing unused objects automatically.
- Java Native Interface: Interacts ****with non-java interfaces.
Garbage Collection (GC) automatically removes unused objects, preventing memory leaks and optimizing performance. It uses the mark-and-sweep algorithm and may call
finalize()
before removal. CallingSystem.gc()
suggests GC execution, but it's not guaranteed.
JVM as a Movie Theater –#
- Class Loader (Ticket Counter & Entry) → Loads Java classes like a theater assigns seats to the audience.
- Memory Area (Theater Sections) → Stores class details (Projector Room), objects (Audience Seats), method calls (Narrator), and execution tracking (Movie Timing System).
- Execution (Movie Playing) →
- Interpreter (Slow Narrator) reads code line by line.
- JIT Compiler (Fast-Forward Mode) speeds up frequently used code.
- Garbage Collector (Cleaning Crew) removes unused objects.
- Java Native Interface (Multilingual Audio) interacts with non-Java components.
Benefits: Importance of JVM - Why is Java essential#
JVM is responsible for Java’s platform-independence, secure, and high-performance features. For these features, Java has become the most popular and powerful language.
1. Platform Independence and Portability:#
WORA: Write Once Run Anywhere principle making Java Platform Independent. Java byte codes run independently on any Operating System (e.g. Windows, Mac, Linux, etc.). JVM provides a runtime environment to achieve this feature. This platform-independent feature makes java portable.
2. Automatic Memory Management and Error Checking and Debugging:#
JVM automatically manages memory for Java programs. To prevent unnecessary memory leaks, JVM provides a Garbage Collector to clean up unused memories.
The interpreter provides to check the code line by line, it can easily identify and report errors immediately when they occur, making debugging simpler.
Developers can quickly fix bugs because the error is pointed out directly at the problematic line of code.
3. Security:#
The Security Manager in JVM helps manage access permissions, ensuring that Java applications don’t perform unsafe operations (like accessing restricted files or modifying system settings).
4. Performance Optimization:#
By using JIT Compiler (Just In Time) of JVM, Java byte codes are converted into a native machine code during runtime. It helps to run java code faster way and improves the overall performance.
5. Multithreading Support:#
The JVM supports multithreading, which allows java programs to perform multiple tasks at once. This is useful in applications like web servers and mobile apps where multiple users or tasks need to be handled simultaneously.
6. Java Ecosystem#
The JVM supports a wide range of libraries, frameworks, and tools that make Java development easier. The rich ecosystem of libraries, such as Spring for web applications and Hibernate for database management, is made possible by the JVM.
Conclusion:#
JVM powers Java’s platform independence, security, and high performance, enabling the "Write Once, Run Anywhere" (WORA) principle. Its automatic memory management, JIT compilation, and multithreading optimize execution and debugging. Understanding JVM helps developers build efficient, scalable, and secure applications.