Java Virtual Machine (JVM)

Amalakanthan R
3 min readMay 14, 2021

The basic definition of JVM ( Java Virtual Machine) is “ A program which is used to execute or build other programs. In other words, JVM is used to convert byte code into source code. Thus, the above mentioned definitions are not really enough.

The JVM is a portable virtual machine that runs Java class files. The JVM is a virtual machine, which means it is an approximation of an underlying, real machine, such as the server where your software runs. The JVM provides a predictable environment for programs to run in, regardless of what operating system or hardware is currently present. Therefore, the JVM does not create a virtual operating system instead it creates a runtime environment.

When discussing about virtual machines, a virtual machine is a simulation which actually makes the surrounding as real. The term “Virtual” is referred to as “non- real existence”. Therefore a virtual machine acts like a machine which is really not physically visible but acts like a simulation.

Virtual machines are of two types they are:

● SVM

● AVM

SVM is a system based virtual machine while AVM is an application based virtual machine. SVM can have one or more hardware and SVM can have multiple instances and can be used by multiple users at a time. The suitable examples of SVM are “Hypervisor” and “XEN”. while AVM is totally opposite of SVM. AVM does not involve or don’t have any hardwares. AVM is an application based virtual machine which helps to create platforms in order to run other programs. The most suitable examples of AVM are JVM, PVM and CLR. AVM can also be termed as “Process based virtual machine”.

Therefore the Java Virtual machine is one of the application based virtual machines. So when installing the JRE, along with JRE the JVM also gets installed. Which means when a java program is running, automatically the java virtual machines get existed. For example if there are three programs running on the computer, then there is JVM which gets initiated for three different programs. So whenever the program gets ended, then the JVM which is particularly running for the particular program also gets ended. Therefore JVM will run when there is an instance of a program running on the machines. Therefore, the byte codes are converted into source code when the program is run on the computer with the help of java virtual machine.

The JVM starts with a non-daemon thread and exits when the non-daemon thread gets closed. Therefore there are two ways when a JVM gets exit. The first method, when the non-daemon thread gets exit and the other method is when the application calls for exit method which is also known as “Sucide method”.

Components in a JVM

● Class Loader

● Memory area

● Execution Engine

The above mentioned are the components in a JVM and those components play a major role while the JVM is functioning when the program is executed. There are sub-components under the component called “Memory Area”. Some of the sub components in the Memory Area are: method area, heap area,stack,pc registers,native method area.

All the class information is loaded in the method area, while all the objects in the class comes to heap area. Stack will be holding the information and create a frame to each thread and then if the method is not native, pc registers will hold up the information for the execution. Suppose if there is any native method then the information is held in the native area.

--

--