Java Virtual Machine

you are watching: Java Virtual Machine here hiddentracks.org


Java Virtual Machine

The compilation process in
Java: JVM

Review:

High level programming languages are not understood directly by a computer,
so they must be converted somehow to machine language. This translation
is done by compilers (the whole program is translated into machine
language and then executed) and interpreters (the program is translated
and executed one line at a time; much slower than compilers). Java uses
a hybrid strategy: instead of compiling into machine language, Java programs
are compiled into an intermediate language (Java bytecodes) that
serves as the machine language for a theoretical/virtual computer (JVM
=  Java Virtual Machine
). Java then interprets  those programs
by simulating the JVM.


More about JVM:

The Java compiler does not translate your program into the machine
language for your particular computer. Instead, it translates your Java
program into a language called bytecode. Bytecode is not the machine
language for any particular computer; it is the machine language for a
hypothetical/teoretical/virtual computer that is something like the average
of all computers. This hypothetical computer is called the Java Virtual
Machine (JVM)
. JVM is not exactly like any particular computer, but
it is similar to all typical computers, so it is very easy to translate
a program written in bytecode into a program in the machine language for
any particular computer. The program that does this translation is the
Java
interpreter
. The interpreter works by translating each instruction
of bytecode into instructions expressed in your computer’s machine language
and then executing those instructions on your computer. This means that
the interpreter translates and executes the instructions in bytecode one
after the other, rather than translating the entire bytecode program at
once. However, the only detail that you really need to know is that the
interpreter allows your computer to run Java bytecode.

So, why add the extra step to the compilation process? Why not a regular
compiler that translates directly from Java to the machine language of
a particular

computer, as it is done by most programming languages? After all, compilers
produce programs in machine-language and typically they run faster. The
answer is: portability. After compiling a Java program into bytecode,
that bytecode can be used on any computer. When the program is run/executed
on another type of computer, there is no need to recompile it. Advantages:

1. Can send bytecode over the Internet to another computer and have
it run easily on that computer –> Java works well for Internet applications.

2. When a manufacturer comes out with a new type of computer, Sun Microsystems
doesn’t have to design a new Java compiler. The Java compiler works on
every computer –> Java can be added to a new computer very quickly and
very economically (the computer still needs to have a Java bytecode interpreter,
but, compared to a compiler, an interpreter is a simple program.)

 

READ:  Minor in Physics


View more information: http://orion.towson.edu/~izimand/236/LectureNotes/L2_JVM.htm

See more articles in category: Grammar

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button