Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what executes the jvm ??

 
deepak mishra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was reading class-loaders from the book "core java 2 vol 2", when i came across the following lines:
"A Java compiler converts source into the machine language of a hypothetical machine, called the virtual machine. The virtual machine code is stored in a class file with a .class extension."
what i have read till now, the instance of the classes i make are run(interpreted) by JVM; but (as stated above) since JVM itself is an instance of a class , what interprets the JVM itself ??

the book further says :
"These class files must be interpreted by a program that can translate the instruction set of the virtual machine into the machine language of the target machine."
what is "a program" here ??

thanks.
 
Campbell Ritchie
Sheriff
Posts: 48921
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"dpux..." please check your private messages about an important administrative matter.
 
Bill Cruise
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JVM is not a class file itself, but a program that can be written in C or C++, or any compiled language. When you launch your program using at the command line, you're launching your system's JVM with your class name as an argument. The JVM was provided for your operating environment (probably by Sun, IBM, or an open source distribution) so that you can run programs written in Java.

When Core Java 2 says "The virtual machine code is stored in a class file with a .class extension.", it is referring to the byte code for the classes that you write, not the code for the JVM.

In the second part of your question, "a program" does refer to the JVM.
 
deepak mishra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks bill.
i got you, just one more query, is it wrong saying that JVM is a process and each time we run a program calling "java xxx" , we create a new JVM ?
if it IS so, then what if we run 10 programs :
java 1
java 2
.
.
java 10

will there be 10 JVMs loaded in the memory as processes ??
 
Campbell Ritchie
Sheriff
Posts: 48921
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"dpux forlinux" please read your private messages again.
 
Bill Cruise
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, every call to "java xxx" creates a separate process to run a new JVM. These separate JVMs all have their own area of memory and their own call stacks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic