File APIs for Java Developers
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JVM" Watch "JVM" New topic


Pratibha Nandwana

Joined: Mar 03, 2005
Posts: 5
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: 656

JVM is for Java Virtual Machine.
Any Java file (say 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

Sherry Jacob
Ranch Hand

Joined: Jun 29, 2005
Posts: 128
Originally posted by Pratibha Nandwana:

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

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!

I agree. Here's the link:
subject: JVM