Home » Java » Core Java » Introduction to Java Virtual Machine (JVM)

About Annamalai Thangaraj

Annamalai Thangaraj
Annamalai is a Software Engineer with 2+ years experience in Java, Spring, Struts, Hibernate, IDM/IAM, and Enterprise Web Application Development.

Introduction to Java Virtual Machine (JVM)

What is JVM

Java virtual machine (JVM) is an abstract computing machine that enables a computer to run a Java program.

There are three notions of the JVM:

1. Specification

2. Implementation

3. Instance.

The specification is a document that formally describes what is required of a JVM implementation. Having a single specification ensures all implementations are inter-operable. A JVM implementation is a computer program that meets the requirements of the JVM specification. An instance of a JVM is an implementation running in a process that executes a computer program compiled into Java bytecode.

Java Runtime Environment (JRE)

Java Runtime Environment (JRE) is a software package that contains what is required to run a Java program. It includes a Java Virtual Machine implementation together with an implementation of the Java Class Library. The Oracle Corporation, which owns the Java trademark, distributes a Java Runtime environment with their Java Virtual Machine called HotSpot.

Java Development Kit (JDK)

Java Development Kit (JDK) is a superset of a JRE and contains tools for Java programmers, e.g. a
javac compiler. The Java Development Kit is provided free of charge either by Oracle Corporation directly, or by the OpenJDK open source project, which is governed by Oracle.

What JVM does

The JVM performs following operation:

  • Loads code
  • Verifies code
  • Executes code
  • Provides runtime environment

JVM provides definitions for the:

  • Memory area
  • Class file format
  • Register set
  • Garbage-collected heap
  • Fatal error reporting etc.

Java Virtual Machine Architecture

 

1. Classloader : Classloader is a subsystem of JVM that is used to load class files.

2. Class(Method) Area : Class(Method) Area stores per-class structures such as the runtime constant pool, field and method data, the code for methods.

3. Heap : It is the runtime data area in which objects are allocated.

4. Stack : Java Stack stores frames.It holds local variables and partial results, and plays a part in method invocation and return.

Each thread has a private JVM stack, created at the same time as thread. A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes.

5. Program Counter Register : PC (program counter) register. It contains the address of the Java virtual machine instruction currently being executed.

6. Native Method Stack : It contains all the native methods used in the application.

7. Execution Engine : It contains:

  1. A virtual processor
  2. Interpreter: Read bytecode stream then execute the instructions.
  3. Just-In-Time(JIT) compiler

Reference

:
https://en.wikipedia.org/wiki/Java_virtual_machine

Published on Java Code Geeks with permission by Annamalai Thangaraj, partner at our JCG program. See the original article here: Introduction to Java Virtual Machine (JVM)

Opinions expressed by Java Code Geeks contributors are their own.

(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of