JVM (Java Virtual Machine)
- JVM (Java Virtual Machine) is an abstract machine. It is called a virtual machine because it doesn't physically exist. It is a specification that provides a runtime environment in which Java bytecode can be executed. It can also run those programs which are written in other languages and compiled to Java bytecode.
- JVMs are available for many hardware and software platforms. JVM, JRE, and JDK are platform dependent because the configuration of each OS is different from each other. However, Java is platform independent. There are three notions of the JVM: specification, implementation, and instance.
-
The JVM performs the following main tasks:
- Loads code
- Verifies code
- Executes code
- Provides runtime environment
- The JDK contains a private Java Virtual Machine (JVM) and a few other resources such as an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), etc. to complete the development of a Java Application.
What is JVM
It is:
- A specification where working of Java Virtual Machine is specified. But implementation provider is independent to choose the algorithm. Its implementation has been provided by Oracle and other companies.
- An implementation Its implementation is known as JRE (Java Runtime Environment).
- Runtime Instance Whenever you write java command on the command prompt to run the java class, an instance of JVM is created.
What it does
The JVM performs following operation:
- Loads code
- Verifies code
- Executes code
- Provides runtime environment
- Memory area
- Class file format
- Register set
- Garbage-collected heap
- Fatal error reporting etc.
JVM provides definitions for the:
JVM Architecture
Let's understand the internal architecture of JVM. It contains classloader, memory area, execution engine etc.