I have heard people saying "a JVM is necessarily a java interpreter but a java interpreter is not necessarily a JVM". Is that true?
I mean is there a difference between java interpreter and JVM?
views:
235answers:
4For one, code from (theoretically) any language can be compiled down to JVM bytecodes to allow execution within that environment. A Java interpreter is only able to run Java code.
Calling a JVM a Java interpreter is incorrect. The JVM is a JIT compiler that compiles and runs byte-code. Other languages can be compiled into byte-code targeted for the JVM. Wikipedia article detailing such languages.
Yes there is difference.
Java virtual machine:
A software "execution engine" that safely and compatibly executes the byte codes in Java class files on a microprocessor (whether in a computer or in another electronic device).
Java interpreter:
A module that alternately decodes and executes every statement in some body of code. The Java interpreter decodes and executes bytecode for the Java virtual machine
The Java interpreter is actually a part of JVM. Virtual machine is not just executing the bytecodes, it has lot of tasks to do. That full-fledged environment is referred to as JVM.
check:
http://en.wikipedia.org/wiki/Java_Virtual_Machine
http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136373.html
As I understand it...
A Java interpreter executes lines of byte code as commands to be executed. The byte code is executed.
The JVM takes the byte code and generates machine code. The byte code is compiled to machine code, and the machine code is executed.