Java Virtual Machine (JVM) is an abstract virtual machine (basically, a program) that resides on your computer and provides a runtime environment for the Java bytecode (you program code after compilation) to get executed.
JVM analyze the bytecode, interprets it, and execute the same bytecode to display the output.
The basic function of JVM is to execute the compiled .class files (i.e. the bytecode) and generate an output. Do note, each operating system has a different JVM, but the generated bytecode output is the same across all operating systems. This means that the bytecode generated on Windows OS can also run on Linux OS and vice-versa, thus making Java as a platform independent language.
So, we can say that the JVM performs the following operations:
- Loading of the required .class and jar files
- Assigning references and verification of the code
- Execution of the code
- Provides a runtime environment for the Java bytecode
JRE (Java Runtime Environment), is JVM combined with the development tools needed to develop JVM compatible programs.
Check out the article to learn more about JVM.