SlideShare a Scribd company logo
JAVA ROADMAP
JVM Architecture – How It Works
Introduction
Java, a widely used programming language known for its versatility and
reliability, owes much of its power to the Java Virtual Machine (JVM)
Architecture. Let’s examine the JVM’s function in executing Java programs
and how it enables the concept of “Write Once, Run Anywhere” (WORA).
Definition Of JVM
The Java Virtual Machine, commonly referred to as JVM, is a virtual computer
that runs Java code. It acts as a translator between the computer’s native
language and your Java code. Consider it as a skilled interpreter who can
translate your words so that speakers of many languages understand you.
Importance Of JVM In Running Java Applications
The JVM Architecture
plays a vital role in running Java applications, offering benefits that make Java
widely applicable. Its benefits include:
1. Portability
JVM’s magic lies in its ability to make Java code portable across different
systems. It’s like a universal charger that allows you to plug in your electronic
devices, such as smartphones, tablets, or laptops, regardless of the
manufacturer. The charger handles the voltage and power requirements,
making it possible to use your devices worldwide without needing different
chargers for each country.
2. Memory Management in JVM Architecture
JVM takes care of memory management, ensuring your Java application runs
smoothly. Consider a closet organizer that optimizes space utilization by
intelligently arranging clothes, shoes, and accessories. Similarly, the JVM
efficiently allocates and releases memory for objects, keeping your program’s
memory usage in check and preventing memory-related issues.
3. Exception Handling in JVM Architecture
JVM acts as a problem solver, dealing with errors that occur during program
execution. Think of it as a safety net during a trapeze performance. If a
trapeze artist loses grip and falls, the net catches them, preventing a
disastrous outcome. Similarly, JVM detects errors or exceptions in your code
and gracefully handles them, preventing your program from crashing and
helping you identify and resolve issues.
WORA And Its Relation To JVM Architecture
WORA, or “Write Once, Run Anywhere,” is a key advantage of Java, made
possible by the JVM Architecture. Imagine writing a letter in your native
language and being able to share it with people around the world who speak
different languages. The recipients use their respective translators to
understand your message. Similarly, the JVM serves as a translator, enabling
Java code to be written once and run on any system with a compatible JVM.
The JVM simplifies running Java programs on different systems. It’s like a
universal remote that works with any TV, saving you from having multiple
remotes for different TVs.
JVM Architecture
The JVM Architecture is like a smart assistant that helps your computer
understand and execute Java programs. Let’s explore its architecture, which
consists of three key parts:
1. Class Loader
The class loader is like a librarian that finds and organizes the Java classes
your program needs, making sure everything is ready to go.
2. Runtime Data Area
The runtime data area serves as memory storage for different program
execution components, similar to a workspace that has multiple divisions.
1. Method Area
2. Heap Area
3. Stack Area
4. PC Register
5. Native Method Stack Area
3. Execution Engine
The execution engine acts as a skilled translator, converting your Java code
into a language that your computer can understand and execute. It does this
through two methods:
1. Interpreter
2. JIT Compiler
Compilation of .java files and creation of .class files
When you write Java code in a .java file, it’s in a human-readable form. The
process of transforming this code into bytecode is similar to compiling a
document into a PDF format. The Java compiler (javac) compiles the .java file
and generates bytecode instructions that can be understood by the JVM.
These bytecode instructions are stored in .class files, which contain the binary
representation of your code.
Steps involved in running .class files:
When you run a Java program, the JVM takes over the execution process.
Here are the steps involved:
1. Class Loading: The JVM’s class loader locates and loads the required
.class files into memory.
2. Bytecode Verification: The bytecode verifier ensures that the
bytecode is valid and doesn’t violate any security rules. It’s like a
security checkpoint👮💼 that scans your luggage at the airport to
ensure there are no prohibited items.
3. Execution: The JVM’s execution engine interprets the bytecode
instructions or dynamically compiles them into machine code using
the JIT compiler. The bytecode instructions are executed, and the
program’s logic is carried out.
4. Memory Management: The JVM manages memory allocation and
deallocation. It automatically handles memory usage, freeing up
memory occupied by objects that are no longer needed.
5. Exception Handling: The JVM detects and handles exceptions that
occur during program execution. It ensures that your program
doesn’t crash when unexpected situations arise, just like a safety net
that catches you when you stumble.
Now let’s deep dive into the working and functioning of JVM i.e. JVM
Architecture.
ClassLoader Subsystem In JVM Architecture
1. Introduction
Have you ever wondered how Java programs easily load and run many
classes? The Class Loader Subsystem, an important component of the Java
Virtual Machine (JVM), holds the key to the answer. Let’s explore the Class
Loader Subsystem’s operations, understand its function in loading classes,
and inspect its key components.
2. Understanding the ClassLoader Subsystem
Consider the Class Loader Subsystem as your trusted friend who helps in
finding and loading the classes your Java program requires. Similar to a
diligent librarian, it finds the necessary class files and brings them into
memory so they are available for use. When your program needs the right
classes, the Class Loader Subsystem ensures that they are easily available.
3. Components of the ClassLoader Subsystem:
The Class Loader Subsystem consists of different components, each playing a
crucial role in the class loading process. Let’s explore them one by one:
1. Bootstrap Class Loader:
This is like the superhero of class loaders, responsible for loading the core
Java classes that are part of the Java Development Kit (JDK). It’s the first
class loader that comes into action when the JVM starts up. Just as a
superhero lays the foundation for a story, the Bootstrap Class Loader provides
the essential building blocks for your Java programs.
2. Extension Class Loader:
Imagine you have some additional modules or libraries that enhance the
functionality of your Java program. The Extension Class Loader helps in
loading these extra modules, extending the capabilities of the core Java
classes. It’s like a friendly assistant who fetches the special tools you need to
enhance your work.
3. System/Application Class Loader:
Now, think of the System/Application Class Loader as your personal courier
service. It delivers the classes specific to your application, including the ones
you’ve created, to the JVM. This class loader looks into the classpath of your
application and ensures that all your custom classes are loaded correctly.
VISIT
BLOG.GEEKSTER.IN
FOR THE REMAINING
QUESTIONS

More Related Content

Similar to JVM Architecture – How It Works.pdf

Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
Harry Potter
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
James Wong
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Fraboni Ec
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Young Alista
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Luis Goldster
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
Hoang Nguyen
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
Tony Nguyen
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
Satyam Pandey
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
Mukesh Tekwani
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
Java the reason behind its never ending demand
Java the reason behind its never ending demandJava the reason behind its never ending demand
Java the reason behind its never ending demand
Deepika Chaudhary
 
Inside JVM
Inside JVMInside JVM
Inside JVM
Chinh Ngo Nguyen
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
Nikhil Sharma
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
WE-IT TUTORIALS
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptx
DrPreethiD1
 
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
10322210023
 
Unit1 JAVA.pptx
Unit1 JAVA.pptxUnit1 JAVA.pptx
Unit1 JAVA.pptx
RahulAnand111531
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
ijaprr_editor
 
Java Virtual Machine.pdf
Java Virtual Machine.pdfJava Virtual Machine.pdf
Java Virtual Machine.pdf
Uncodemy
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8kumar467
 

Similar to JVM Architecture – How It Works.pdf (20)

Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Java the reason behind its never ending demand
Java the reason behind its never ending demandJava the reason behind its never ending demand
Java the reason behind its never ending demand
 
Inside JVM
Inside JVMInside JVM
Inside JVM
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptx
 
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
 
Unit1 JAVA.pptx
Unit1 JAVA.pptxUnit1 JAVA.pptx
Unit1 JAVA.pptx
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
 
Java Virtual Machine.pdf
Java Virtual Machine.pdfJava Virtual Machine.pdf
Java Virtual Machine.pdf
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8
 

More from Geekster

Constructors In Java – Unveiling Object Creation
Constructors In Java – Unveiling Object CreationConstructors In Java – Unveiling Object Creation
Constructors In Java – Unveiling Object Creation
Geekster
 
Java Polymorphism: Types And Examples (Geekster)
Java Polymorphism: Types And Examples (Geekster)Java Polymorphism: Types And Examples (Geekster)
Java Polymorphism: Types And Examples (Geekster)
Geekster
 
Setting Up Java Environment | PDF
Setting Up Java Environment | PDFSetting Up Java Environment | PDF
Setting Up Java Environment | PDF
Geekster
 
OOps Interview questions.pdf
OOps Interview questions.pdfOOps Interview questions.pdf
OOps Interview questions.pdf
Geekster
 
2 Important Data Structure Interview Questions
2 Important Data Structure Interview Questions2 Important Data Structure Interview Questions
2 Important Data Structure Interview Questions
Geekster
 
What are the 7 features of Python?pdf
What are the 7 features of Python?pdfWhat are the 7 features of Python?pdf
What are the 7 features of Python?pdf
Geekster
 

More from Geekster (6)

Constructors In Java – Unveiling Object Creation
Constructors In Java – Unveiling Object CreationConstructors In Java – Unveiling Object Creation
Constructors In Java – Unveiling Object Creation
 
Java Polymorphism: Types And Examples (Geekster)
Java Polymorphism: Types And Examples (Geekster)Java Polymorphism: Types And Examples (Geekster)
Java Polymorphism: Types And Examples (Geekster)
 
Setting Up Java Environment | PDF
Setting Up Java Environment | PDFSetting Up Java Environment | PDF
Setting Up Java Environment | PDF
 
OOps Interview questions.pdf
OOps Interview questions.pdfOOps Interview questions.pdf
OOps Interview questions.pdf
 
2 Important Data Structure Interview Questions
2 Important Data Structure Interview Questions2 Important Data Structure Interview Questions
2 Important Data Structure Interview Questions
 
What are the 7 features of Python?pdf
What are the 7 features of Python?pdfWhat are the 7 features of Python?pdf
What are the 7 features of Python?pdf
 

Recently uploaded

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 

JVM Architecture – How It Works.pdf

  • 1. JAVA ROADMAP JVM Architecture – How It Works Introduction Java, a widely used programming language known for its versatility and reliability, owes much of its power to the Java Virtual Machine (JVM) Architecture. Let’s examine the JVM’s function in executing Java programs and how it enables the concept of “Write Once, Run Anywhere” (WORA). Definition Of JVM The Java Virtual Machine, commonly referred to as JVM, is a virtual computer that runs Java code. It acts as a translator between the computer’s native language and your Java code. Consider it as a skilled interpreter who can translate your words so that speakers of many languages understand you. Importance Of JVM In Running Java Applications The JVM Architecture plays a vital role in running Java applications, offering benefits that make Java widely applicable. Its benefits include:
  • 2. 1. Portability JVM’s magic lies in its ability to make Java code portable across different systems. It’s like a universal charger that allows you to plug in your electronic devices, such as smartphones, tablets, or laptops, regardless of the manufacturer. The charger handles the voltage and power requirements, making it possible to use your devices worldwide without needing different chargers for each country. 2. Memory Management in JVM Architecture JVM takes care of memory management, ensuring your Java application runs smoothly. Consider a closet organizer that optimizes space utilization by intelligently arranging clothes, shoes, and accessories. Similarly, the JVM efficiently allocates and releases memory for objects, keeping your program’s memory usage in check and preventing memory-related issues. 3. Exception Handling in JVM Architecture JVM acts as a problem solver, dealing with errors that occur during program execution. Think of it as a safety net during a trapeze performance. If a trapeze artist loses grip and falls, the net catches them, preventing a disastrous outcome. Similarly, JVM detects errors or exceptions in your code and gracefully handles them, preventing your program from crashing and helping you identify and resolve issues. WORA And Its Relation To JVM Architecture WORA, or “Write Once, Run Anywhere,” is a key advantage of Java, made possible by the JVM Architecture. Imagine writing a letter in your native
  • 3. language and being able to share it with people around the world who speak different languages. The recipients use their respective translators to understand your message. Similarly, the JVM serves as a translator, enabling Java code to be written once and run on any system with a compatible JVM. The JVM simplifies running Java programs on different systems. It’s like a universal remote that works with any TV, saving you from having multiple remotes for different TVs. JVM Architecture The JVM Architecture is like a smart assistant that helps your computer understand and execute Java programs. Let’s explore its architecture, which consists of three key parts: 1. Class Loader The class loader is like a librarian that finds and organizes the Java classes your program needs, making sure everything is ready to go. 2. Runtime Data Area The runtime data area serves as memory storage for different program execution components, similar to a workspace that has multiple divisions. 1. Method Area 2. Heap Area 3. Stack Area 4. PC Register 5. Native Method Stack Area 3. Execution Engine The execution engine acts as a skilled translator, converting your Java code into a language that your computer can understand and execute. It does this through two methods:
  • 4. 1. Interpreter 2. JIT Compiler Compilation of .java files and creation of .class files When you write Java code in a .java file, it’s in a human-readable form. The process of transforming this code into bytecode is similar to compiling a document into a PDF format. The Java compiler (javac) compiles the .java file and generates bytecode instructions that can be understood by the JVM. These bytecode instructions are stored in .class files, which contain the binary representation of your code. Steps involved in running .class files: When you run a Java program, the JVM takes over the execution process. Here are the steps involved: 1. Class Loading: The JVM’s class loader locates and loads the required .class files into memory. 2. Bytecode Verification: The bytecode verifier ensures that the bytecode is valid and doesn’t violate any security rules. It’s like a
  • 5. security checkpoint👮💼 that scans your luggage at the airport to ensure there are no prohibited items. 3. Execution: The JVM’s execution engine interprets the bytecode instructions or dynamically compiles them into machine code using the JIT compiler. The bytecode instructions are executed, and the program’s logic is carried out. 4. Memory Management: The JVM manages memory allocation and deallocation. It automatically handles memory usage, freeing up memory occupied by objects that are no longer needed. 5. Exception Handling: The JVM detects and handles exceptions that occur during program execution. It ensures that your program doesn’t crash when unexpected situations arise, just like a safety net that catches you when you stumble. Now let’s deep dive into the working and functioning of JVM i.e. JVM Architecture. ClassLoader Subsystem In JVM Architecture 1. Introduction Have you ever wondered how Java programs easily load and run many classes? The Class Loader Subsystem, an important component of the Java Virtual Machine (JVM), holds the key to the answer. Let’s explore the Class Loader Subsystem’s operations, understand its function in loading classes, and inspect its key components. 2. Understanding the ClassLoader Subsystem Consider the Class Loader Subsystem as your trusted friend who helps in finding and loading the classes your Java program requires. Similar to a diligent librarian, it finds the necessary class files and brings them into memory so they are available for use. When your program needs the right classes, the Class Loader Subsystem ensures that they are easily available.
  • 6. 3. Components of the ClassLoader Subsystem: The Class Loader Subsystem consists of different components, each playing a crucial role in the class loading process. Let’s explore them one by one: 1. Bootstrap Class Loader: This is like the superhero of class loaders, responsible for loading the core Java classes that are part of the Java Development Kit (JDK). It’s the first class loader that comes into action when the JVM starts up. Just as a superhero lays the foundation for a story, the Bootstrap Class Loader provides the essential building blocks for your Java programs. 2. Extension Class Loader: Imagine you have some additional modules or libraries that enhance the functionality of your Java program. The Extension Class Loader helps in loading these extra modules, extending the capabilities of the core Java classes. It’s like a friendly assistant who fetches the special tools you need to enhance your work. 3. System/Application Class Loader: Now, think of the System/Application Class Loader as your personal courier service. It delivers the classes specific to your application, including the ones you’ve created, to the JVM. This class loader looks into the classpath of your application and ensures that all your custom classes are loaded correctly. VISIT BLOG.GEEKSTER.IN FOR THE REMAINING QUESTIONS