JVM (part 1) ~ What Is JVM? (Java Virtual Machine)

A complete journey to understand what is java virtual machine

Shanira Perera
2 min readJul 17, 2022
Programming with MacBook
Image by Author via Unsplash

What is Virtual Machine?

Everyone heard about virtual, Virtual is that something visualize like real but its actually not in reality. that’s mean not physically existing as such but made by software to appear to do so.

Virtual Machine can divided into 2 sections. One is SVM (System Base Virtual Machine) & other one is AVM (Application Base Virtual Machine)

SVM

SVM is a one of a section of virtual machine is has one hardware but it can creates multiple independent environments. Such as hypervisor, Xen

AVM

This is the other section. This one no need any hardware. JVM includes in this section. and other examples we can take is CLR ( for .Net ) and the PVM (parrot virtual machine for Perl).

JVM

JVM is completely specification because when you install JRE (java runtime enviornment) it includes the JVM. Now we had an idea about what is virtual machine and what are the types of it. So now we look into what is JVM and What is it purpose.

When we programming or coding using IDE and after compiling it, it will convert to ByteCode. But machine can’t identify the ByteCode so we need to convert it to machine code. In this point we need some mechanism to do it. JVM helps to do this step it convert the ByteCode to MachineCode. That was the process of the JVM.

Process of JVM

JVM starts to execute when the program is compiling. and it dies when the program is exit. Think, you have to run many program in the same time. It doesn’t run a single jvm instance, it runs individually instance for those particular programs. Ex: ( 4 different JVM instance run for 4 different programs ). when type java keyword in the command prompt it creates daemon thread ok now you think what is daemon thread is.

When the JVM instance create it called the method of “public static void main()” in that method must include the public & void keywords then its execute. after that onward the program can drive through this method.

Termination of JVM

There are 2 ways of termination methods. one is if there are no non-daemon threads are exist that mean all the non-daemon threads are destroyed or closed jvm also stop with that.

If the Exit() method calls that moment, it also causes to application commit suicide. application close means jvm also die with that.

programming
Image by Author via Unsplash

--

--

Shanira Perera

Hello, I’m Shanira, welcome to the world of technology. I am an Associate software engineer at virtusa. So let’s begin!