JVM: Java Virtual Machine

By | March 29, 2022
Java Virtual Machine

Java virtual machine is an abstract machine that provides you with the runtime environment to execute Java bytecode. JVM depends on the underlying platform. JVM is not compatible with many hardware and software. 

What is JVM (Java Virtual Machine)?

JVM is a specification that specifies the working of JVM. but the algorithm will be chosen by their implementation provider. JVM’s implementation is provided by Oracle and other companies. JVM is also an implementation which is specified by JRE. JVM is a runtime instance which will be created whenever you run the java class. 

JVM allows you to perform some operations like- loading the code, verifying the code, executing the code, and providing a runtime environment. 

JVM Architecture

JVM architecture defines- classloader, memory area, execution engine, etc.Java Virtual Machine

1. Classloader

Classloader will load the Java class file and is a subsystem of JVM. When we run a Java program it will be loaded by classloader. You can create a customized class loader which has to extend the classloader class. Java has three built-in classloader-

  • Bootstrap ClassLoader-: This is the superclass of the Extension ClassLoader. It enables the loading of rt.jar files which holds Java standard edition class files. 
  • Extension ClassLoader: This classloader is the subclass of the Bootstrap classloader and the parent for the system classloader. It will help in loading the jar files from the extension directory.
  • System ClassLoader: Also known as the application classloader and is a child of the Extension classloader. It helps in loading the class file from the classpath. You can change the classpath using -cp or the -classpath command. Classpath points to the current directory by default. 

2. Class Area

The class area allows you to store the structure of per-class like- runtime constant pool, method and method codes.

3. Heap

Heap is used to allocate objects and is a runtime data area.

Vamware

4. Stack

Java stacks are used to store stacks which contain the local variable and the partial results. JVM stack is created with each thread and each thread has its stack. This frame will be created with the method invocation and destroyed when the method invocation finishes.

5. Program Counter Register

This counter will hold the address of the instruction which will be executed by the Java Virtual Machine.

Vamware

6. Execution Engine

It consists of- a virtual processor, interpreter, and the JIT compiler.

7. Java Native Interfaces

This is a Java framework used as an interface to communicate with programs written in a different language. It allows sending the output to the console or to connect with OS libraries.

Conclusion

Java Virtual Machine (JVM) enables Java programs to run on different computer systems. It is responsible for converting bytecode into machine code. Moreover, JVM can execute code written in any other programming language that has been converted into Java bytecode.

We hope that this article helped you understand JVM and its architecture. If you have any doubts or queries, feel free to share them in the comments section below.

People are also reading: 

Vamware
Author: Ramya Shankar

A cheerful, full of life and vibrant person, I hold a lot of dreams that I want to fulfill on my own. My passion for writing started with small diary entries and travel blogs, after which I have moved on to writing well-researched technical content. I find it fascinating to blend thoughts and research and shape them into something beautiful through my writing.

Leave a Reply

Your email address will not be published.