Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
1.1.
What is JVM?
1.2.
Working Of JVM
1.3.
JVM Architecture
2.
Frequently Asked Questions
2.1.
What is the architecture of JVM?
2.2.
What are the responsibilities of JVM?
3.
Conclusion
Last Updated: Mar 27, 2024

JVM and Its architecture

gp-icon
Data structures & algorithms (Beginner to Intermediate)
Free guided path
13 chapters
99+ problems
gp-badge
Earn badges and level up

Introduction

JVM (Java Virtual Machine) is an abstract machine. It is a special type that provides a runtime environment in which byte code can be exected. JVM is available for hardware and software platforms. It is the one that calls the main which is present in a java code. It is a part of JRE(Java Runtime Environment).

You can also read about the topic of Java Destructor.

Also, See -  Iteration Statements in Java, Duck Number in Java  and Swap Function in Java

What is JVM?

Java applications are called WORA(Write Once Run Anywhere). It means a programmer can code in Java and execute on any other Java-enabled system without any adjustment. Java compiler produces machine code for a particular system known as Java Virtual Machine. 

Working Of JVM

First, the code is compiled and converted into bytecode. 

  • This bytecode is interpreted on different machines. Between the host system and Java source, bytecode is an intermediate language. 
  • In JVM, Java is responsible for allocating memory space. 
  • JVM performs different tasks like it loads the code, verifies it, executes the code, and provides a runtime environment. 
  • It provides definitions for the memory area, class file format, register set, garbage collector heap, fatal error reporting, etc.

JVM Architecture

Java Architecture is internally basically divided into seven segments. It contains a classloader, memory area, execution, etc. 

  • Classloader: it's a subsystem of JVM used to load class files. When we execute the code, it's loaded by the classloader. There are built-in classloaders in Java.
  1. Bootstrap ClassLoader: This is the first classloader, the superclass of the Extension classloader. It loads the rt.jar file, which contains all files of Java Standard Edition like Java.lang package classes, java.net package classes.

2. Extension ClassLoader: This is the child classloader of Bootstrap and parent classloader of System classloader.
3. System/Application Classloader: It loads the class files from classpath. It is also known as the Application classloader.

  • Class(Method)Area: Class (Method)Area stores per-class structures such as the constant runtime pool, field and method data, and the form code.
  • Heap: It is the runtime method where objects are allocated.
  • Stack: It stores frames and holds local variables and partial results and plays a part in method invocation and return.
  •  Program Counter Register: This register contains the address of the Java Virtual machine instruction, which is currently being executed. 
  • Native Method Stack: It has all the native methods applicable in the application. 
  • Execution Engine: This consists of three parts:
  1. A virtual processor:
  2. Interpreter:
  3. Just-In-Time(JIT) compiler:
  •  Java Native Interface: It is a framework that facilitates an interface to communicate with another application coded in other languages like C++, C, Assembly, etc. Java uses this framework to send output to the console to interact with OS libraries.

You can also check about Java Tokens and Hashcode Method in Java here.

Frequently Asked Questions

What is the architecture of JVM?

JVM is the engine that drives the Java Code. It converts Java bytecode into machine language. JVM architecture in Java contains classloader, memory area, execution engine, etc.

What are the responsibilities of JVM?

The JVM has two primary functions: to allow Java programs to run on any device or operating system (known as the "Write once, run anywhere" principle) and to manage and optimize program memory.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Conclusion

In this article, we cover several topics regarding JVM and its architecture:

  • A Brief Description of what is JVM.
  • How JVM works?
  • Working on JVM and its architecture.
     

Related article: 

Difference between JDK, JRE and JVM 

Java Ioexception

Addressing Modes of 8086

Why is Java Platform Independent

Data Warehouse Architecture

Addition of two numbers in java

how to run java program

If you want to learn more about JVM, you can go to this website JVM.

Previous article
Robust Meaning in Java
Next article
Java Program to Compute GCD
Guided path
Free
gridgp-icon
Data structures & algorithms (Beginner to Intermediate)
13 chapters
109+ Problems
gp-badge
Earn badges and level up
Live masterclass