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 ??
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.
Joined: Jul 21, 2008
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 ??
Joined: Oct 13, 2005
"dpux forlinux" please read your private messages again.
Joined: Jun 01, 2007
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.