This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JVM" Watch "JVM" New topic
Author

JVM

Pratibha Nandwana
Greenhorn

Joined: Mar 03, 2005
Posts: 5
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 ?
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

JVM is for Java Virtual Machine.
Any Java file (say HelloWorld.java) is compiled into a ".class" (say HelloWorld.class) file.

JVM uses the .class file to run your program.

This is a very Basic information on JVM.
However if you want to learn JVM in detail you can learn it here in detail:

JVM Specification


If you are not laughing at yourself, then you just didn't get the joke.
Sherry Jacob
Ranch Hand

Joined: Jun 29, 2005
Posts: 128
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.

Hope this helps


<strong><br />Cheers !!<br /> <br />Sherry<br /></strong><br />[SCJP 1.4]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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
 
 
subject: JVM