In this article we will look at Java Virtual Machine (JVM) which provides the run-time engine for bytecode generated by the Java compiler. We will look at JVM architecture and more.
Introduction
Before learning about JVM it is important to know about JDK (Java Development Kit) and JRE (Java Runtime Environment). Below figure shows the relationship between JDK, JRE, and JVM:
JDK provides programmers with a set of tools (like javac, debugger, javap, appletviewer etc..) for developing Java programs. JDK includes JRE.
JRE provides the run-time engine JVM along with the class libraries which contains the predefined functionality.
Using JDK programmers can create and run Java programs. But with JRE alone, programmers or users can only run already compiled Java programs. We cannot create Java programs using only JRE.
Java Virtual Machine (JVM) is an abstract computing machine that allows a computer to run programs written in Java. There are three concepts related to JVM:
- Specification
- Implementation
- Instance
The JVM specification is a document which contains formal information about what a JVM implementation should contain. A single specification allows various interoperable implementations.
A JVM implementation is a computer program that meets the requirements given in JVM specification.
An instance of a JVM is an implementation running in a process that executes bytecode. Oracle’s implementation of JVM specification is known as HotSpot. Other famous implementations are JRockit, Kaffe, IBM J9.
Overview of the architecture of JVM is as shown below:
Class Loader
A class loader implementation is a program that should be able to perform the following activities:
- Loading: finds and imports the binary data for a type
- Linking: performs verification, preparation, and resolution (optional)
- Initialization: Invokes Java code that initializes class variables to their proper initial values
Heap
The heap area of JVM is used for dynamic memory allocation. In HotSpot the heap is divided into generations:
- The young generation stores objects whose lifetime is short.
- The old generation stores objects which persist for longer durations.
The permanent generation area stores class definitions and other metadata. This area is removed in Java 8.
More information about Java Virtual Machine can be found here.
Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.
He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.
He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.
How does Oracle’s HotSpot JVM implementation differ from other JVM implementations like JRockit and IBM J9?