Java Virtual Machine
Java Virtual Machine
Java Virtual Machine (JVM) is a virtual machine that resides in the real machine
(your computer) and the machine language for JVM is byte code. This makes
it easier for compiler as it has to generate byte code for JVM rather than different
machine code for each type of machine. JVM executes the byte code generated
by compiler and produce output. JVM is the one that makes java platform
independent.
So, now we understood that the primary function of JVM is to execute the byte
code produced by compiler. Each operating system has different JVM,
however the output they produce after execution of byte code is same
across all operating systems. Which means that the byte code generated on
Windows can be run on Mac OS and vice versa. That is why we call java as
platform independent language. The same thing can be seen in the diagram
below: