• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JVM

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
reply
    Bookmark Topic Watch Topic
  • New Topic