Virtual machine

  • Before understanding what is JVM let us first know what virtual machine is.
  • A virtual machine is a layer of abstraction that gives a program one simplified interface for interacting with a variety of physical computers and their operating systems.

Java virtual machine

• As the name indicates, JVM is not a real hardware machine but a software layer which resembles an hardware platform.

• JVM converts Java byte code into machine language and executes it.

• The byte code can be executed on any platform where there exist JVM.

• JVM‘s are available for many hardware and software platforms.

• The use of the same byte code for all JVM’s on all platforms allows Java to be described as a "write once,  run anywhere" programming language.

• Thus, the JVM is a crucial component of the Java platform.

Flow Diagram of if statement

Components of JVM

1. Byte code verifier

2. Class loader

3. Execution engine

4. Garbage collector

5. Security Manager

Byte code verifier

As the name suggests, bytecode verifier is used to verify the bytecode.

• Bytecode verifier checks for unusual code. • Byte code verifier is a crucial component for security.

Class loader

• Class loader loads java classes into java virtual machine.

• All Java virtual machines include one class loader that is embedded in the virtual machine.

• The main feature of the class loader is that JVM. doesn’t need to have any knowledge about the classes that will be loaded at runtime.

• Class loader reads bytecode and creates the instance of java.lang.class.

Execution engine

• The execution engine helps JVM to convert bytecode into machine code.

• It has two parts: a) Interpreter b) Just-in-time-interpreter

• Execution engine is responsible for executing the instructions contained in the methods of loaded classes.

Garbage collector

• Garbage collection is the process of automatically freeing objects that are no longer referenced by the program.

• It periodically check for the object on heap , whose link is broken so it can collect garbage from heap.

• Garbage collection relieves java programmer from memory management.

Security manager

• Security manage constantly monitors the code.

• It is special java object that is responsible for guarding security policies for java applications.

• It is always consulted before any potentially dangerous operation is requested by a java application.


Points to Remember

Java Virtual Machine (JVM) is platform independent, meaning it can run on different Operating Systems (OS) like Windows or UNIX.

• JVM does not really exist but is created within another environment.

As long as a JVM is available natively to a system, a Java program can run in the system.

• The JVM stands on top of the operating system (OS), which means it is independent of the OS.



• Security

• Cross Platform


• Speed

• Platform Specific Features

Shantanu Das

Best Explanation..Thank a lot