To execute a Java program, you run
a program called a bytecode interpreter,
which in turn reads the bytecodes
and executes your Java program. The
Java bytecode interpreter is often
also called the Java virtual machine
or the Java runtime.
bytecodes are a special set of machine
instructions that are not specific
to any one processor or computer system.
A platform-specific bytecode interpreter
executes the Java bytecodes. The bytecode
interpreter is also called the Java
virtual machine or the Java runtime
Java virtual machine, which is a component
of the runtime system, is responsible
for interpreting the bytecodes and
making the appropriate system level
calls to the native platform. It is
at this point where platform independence
is achieved by Java; the bytecodes
are in a generic form that is only
converted to a native form when processed
by the virtual machine.
The JVM concept allows a layer of
translation between the executable
program and the machine-specific code.
In a non-Java compiler, the source
code is compiled into machine- specific
assembly code. In doing this, the
executable limits itself to the confines
of that machine architecture. Compiling
Java code creates an executable using
JVM assembly directives. The difference
of the two approaches is quite fundamental
to the portability of the executable.
Non-Java executables communicate directly
with the platform's instruction set.
Java executables communicate with
the JVM instruction set, which is
then translated into platform-specific
Java Virtual Machine starts execution
by invoking the method main of some
specified class, passing it a single
argument, which is an array of strings.