If you are not laughing at yourself, then you just didn't get the joke.
Joined: Jun 29, 2005
Originally posted by Pratibha Nandwana: Hi I am unable to understand that what is jvm and why is it called virtual machine ? Also what is meant by loading the class ?
Hello Pratibha, Well as Arun said above, JVM is the acronym for Java Virtual Machine. It is basically a platform used to convert Java Bytecode into machine language.
All other programming languages convert the source code directly into machine code to run on a specific platform (microprocessor architecture or OS) but JVM first converts the source code (.java file) into byte code (.class file) and then into machine understandable code. This conversion into bytecode is what makes Java a platform-independent language since byte code can be understood and interpreted by any microprocessor architecture and by any OS.
Hence your code becomes platform-independent. So JVM is in essence, a Java-processor and since it is a processor, so it is called a machine...rather a virtual machine as it virtually converts the source code into bytecode.
The JVM knows nothing of the Java programming language. It only knows and supports binary format, the class file format. A class file contains Java virtual machine instructions (or bytecodes) and a symbol table, as well as other ancillary information.
Virtual machines are neat tools and have been used for many different reasons in the industry.
Each real machine - hardware and OS combination - runs its own machine language and APIs. If you want to write a C program and run it on many types of real machines you have to compile it to the proper machine langauge for each.
The JVM runs Java byte code as its machine language. It looks at one byte code instruction and figures out what real machine instructions to run. You can compile a Java program to byte code once and run the very same byte code on any JVM. The JVM itself must be written to run on a real machine, but somebody like Sun or IBM does that hard stuff once and you run your programs forever.
As pointed out above, the JVM might (or might not) compile the byte code again into the native machine code for optimal performance. That's not required and it's not something you have to even think about. That's the folks who write the JVM going above and beyond the call of duty to get every bit of efficiency they can find. Hat's off to them!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi