Explain working of Java Virtual Machine (JVM)

Questions by Beena   answers by Beena

Showing Answers 1 - 21 of 21 Answers

Devidas Sonawane

  • Oct 19th, 2005
 

JVM first converts .java file into .class file by using Compiler (.class is nothig but bytecode file.) and Interpretor reads bytecodes that runtime is faster.

  Was this answer useful?  Yes

Mithun

  • Feb 14th, 2006
 

JVM is an abstract computing machine like any other real computing machine which interpretes the byte code( .class file which contains virtual machine instructions ) to a machine dependent native code. The output of JVM ie the native code contains low level instructions which is easily understandable by the micro processors which process the native code to give the desire output.

  Was this answer useful?  Yes

sampra

  • Feb 14th, 2008
 

JVM is the specificaion given by sun we can get it physically as JRE.its task is covert the sourse code to byte code , only jvm can understand the byte code

  Was this answer useful?  Yes

nuttyvarun

  • Feb 19th, 2008
 

A Java Virtual Machine (JVM) is a set of computer software programs and data structures which use a virtual machine model for the execution of other computer programs and scripts. The model used by a JVM accepts a form of computer intermediate language commonly referred to as Java bytecode. This language conceptually represents the instruction set of a stack-oriented, capability architecture.

Though Java Virtual Machines most often run Java (programming language) code, a JVM can also be used for other programming languages. JVMs can also be released by other companies beside Sun (the developer of Java) -- JVMs using the "Java" trademark may be developed by other companies as long as they adhere to the JVM specification published by Sun (and related contractual obligations).

Programs intended to run on a JVM must be compiled into a standardized portable binary format, which typically comes in the form of .class files. A program may consist of many classes in different files. For easier distribution of large programs, multiple class files may be packaged together in a .jar file (short for Java archive).

The JVM runtime executes .class or .jar files, emulating the JVM instruction set by interpreting it, or using a just-in-time compiler (JIT) such as Sun's HotSpot. JIT compiling, not interpreting, is used in most JVMs today to achieve greater speed. Like most virtual machines, the Java Virtual Machine has a stack-based architecture.

  Was this answer useful?  Yes

Java Virtual Machine is the heart of entire java program execution process. It is responsible for taking the .class file and converting each byte code instruction into the machine language instruction that can be executed by the microprocessor. Remember that java compiler is outside the JVM. So .class file is given to the JVM and JVM performs following functions:


First of all it loads the .class file into memory.

Then it verifies whether all the byte code instructions are proper or not.If it finds any instruction suspicious,the execution is rejected immediately.JVM uses Interpreter to verify the byte code.

If byte codes are proper then it allocates necessary memory to execute the program.There are 5 types of memory which is allocated to the java program by the JVM
1 Method area
2 Heap memory
3 Java Stack
4 PC register
5 Native Method stack

JVM also helps in Garbage collection of the Object which are not referenced by any reference variable.



  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions