A Java Virtual Machine (JVM) is a collection of programs and data structures
that uses a virtual
machine to execute computer programs and scripts. The JVM is distributed along with a set of standard
class libraries which implement the Java API
(Application Programming Interface). The virtual machine and API have to be
consistent with each other
and are therefore bundled together as the Java Runtime Environment.
Java Virtual Machines mainly run Java
(programming language) code, while a JVM can also runs other programming
languages. JVM is the main component of the Java
Platform. Java can be both middleware as well as a platform as JVMs are available for many hardware and software
platforms. Since the JVM converts the source code into the byte code that why
java is said to be platform independent language means once the source is
compiled (i.e. once the source code converted into the bytecode) the complied
code can run any platform regarding the platform must have the JVM. The JVM also
provides us a unique features known as Automated
Exception Handling. This Automated
Exception Handling feature provides us a 'root-cause' debugging information for
every software error (exception) regardless of the source code.
Programs that are to be run on a JVM must be compiled into a standardized
portable binary format, that usual comes in the form of .class
files. A program may have several classes in different files. Multiple class files
are packaged together in
file so that large programs can be made easier for their distribution.
Java runtime environment executes .class or .jar files,
follow JVM instruction
set by interpreting it. Java runtime environment can also use just-in-time
compiler (JIT) such as Sun's HotSpot.