Java Programming

What is Java Virtual Machine(JVM)?

In this article, we’ll explain you about what is Java Virtual Machine(JVM)? JVM is a highly platform dependent.

Java code is compiled by the compiler & converted into bytecode. The bytecode generated is platform independent code because it can be run on multiple platform. Write once & run anywhere or compile once & run anywhere. In Java, the executable is a bytecode file which is executed on JVM. This bytecode is a architectural neutral file format.

JVM provides as environment in which bytecode can executed. It is a piece of software that sits on the top of actual platform(OS+processor). As JVM acts like OS & processor it looks after class loading, process management. memory management & at times threads for which Java would have had to rely on the operating system.

It takes the responsibility of converting the bytecode in the executable to the native code understandable by the processor. Different flavours of JVM accept the same bytecode but produces different native code suitable/based to the processor.

What is Java Virtual Machine

What is Java Virtual Machine(JVM)?

Virtual Machine is Combination of Three Things

1. The abstract specification:

Working of JVM is specified. But implementation provider is independent to choose the algorithm. Its implementation has provided by Oracle & other companies.

2. The convert implementation:

Its implementation is known as JRE.

3. A runtime instance:

Whenever you write Java command on CMD to run Java class, an instance of JVM is created.

JVM Performs Following Operations

  1. Loads code(Class Loader)
  2. Verifies code(byte-code verifier)
  3. Executes code
  4. Provides run-time environment

Class Loader:

The Class Loader is utility which closely resembles the loader of the Operating System.

Class Loader is subsystem in JVM that is used to load class files. The loader locates the executable file on the drive & loads its instance as a process on the primary memory so that processor can execute it. Instead of actual processor it is the VM that executes the class file.

The class file can be on secondary storage, over the local network or on the internet. Whenever the class is referred to or is instantiated, the class loader tries locate the file on the system & create its instance on the primary memory.

ByteCode Verifier

It is also the Responsibility of bytecode verifier to see that the bytecode that is in the class file has been generated by an authentic Java compiler. Bytecode verifier checks the code fragments for illegal code that can violate access right to objects.

The JVM needs a bytecode file as its executable. Every executable has header that gives details about the file & also helps identify the file as a valid executable file for that machine. If the file gets corrupted then a bytecode verifier checks it out with the information in the header such as parity check etc. & discards the file if corrupted . This is a means of security that the Java language provides.

In this article, we have explained you about what is Java Virtual Machine(JVM).

Get high performance Intel Xeon dual E5 series server and KVM VPS instantly.

Related Articles