Answer Posted / paul
The Java Virual Machine (JVM) is essentially an interpreter
at its core.
It was designed that way for cross platform compatibility.
i.e. write code once, run anywhere. This was the motto in
the early days. The interpreter takes a .class file and
compiles it in a process called Just In Time (JIT)
compiling. So a programmer doesn't have to worry (as much)
about the code being executed. Take C/C++ files which are
executable files (native code - .exe, .dmg etc.). They
don't need to be interpretd but an exe file for Windows
can't work on say Mac. As long as a Java interpreter has
been written for an OS, the .class file will run.
Because .class files are independent of the machine (at
least the classical 32 and 64, XXX bit machines we have
today) they are essentially vitual executables. They still
need the interpreter (JVM) to read them and execute them.
So .class files are essentially virtual bytecode.
Because they are compiled to this intermediate
representation, they are in effect in a language of their
own - Java bytecode. This means that you can in practice
create your own programming language fron end and target it
to the JVM (many do this eg. Scala,) There are over 100
languages that target the JVM as of writing. They do this
becuase they can avoid writing a backend. The JVM is the
backend, and it's a reliable industrial-grade backend.
So nowadays, the JVM is also like a laboratory for testing
new languages and profiling language performance and
reliability etc.
At it's heart the JVM is essentially a stack processor as
it reads the stack of commands in a .class file.
The name is confusing as the only vurtual things are
the .class files that are created by the Java compiler.
It's better imo to think of the Java compiler (Javac) as a
virtual compiler, and the the Java interpreter (JVM) as an
interpreter. Really both stages - compiling and
interpreting are virtual I guess.
The JVM for this reason is also a good way to learn about
abstract machines (as its basically a window into the
intermediate language). There are many uses for the JVM. I
believe virtual machines like this are timeless technology
and will be around, forever maybe.
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How can we make a class singleton?
Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?
What is a Presistent Object?
How many bits is size_t?
Can a class have an interface?
Explain about narrowing conversion in java?
What is the purpose of extern variable?
Can a final variable be initialized in constructor?
what are the disadvantages of indexes in oracle?
Why can't we make a class private in java?
Can a hashset contain duplicates java?
Can we sort set in java?
Which is fastest collection in java?
Explain reverse a linked list recursive java solution?
Is singleton class immutable?