views:

109

answers:

4

can anybody explain "all java interpreter are JVM but all JVM are not java interpreter" ?

I am really confused as JVM is used for to run java program only or it can do anything else too.

+1  A: 

Maybe it means "some JVMs use just-in-time compiling (JIT) instead of interpreting the VM code"

ammoQ
A: 

You can write an interpreter of any programming language, say, in Java. For example, there is an interpreter of Python made in Java, this means that it runs on the JVM but is not an interpreter of the Java programming language. Take "interpreter" here as a term as loose as possible.

Baltasarq
+2  A: 

A Java Virtual Machine (JVM) can execute Java bytecode. And a Java Compiler can create Java bytecode based on Java source files.

But there are more compilers for other languages (like Scala) that create Java bytecode too which can be execute by a JVM.

BTW - a JVM does not 'interprete Java'. It will interprete byte code and may compile it to machine code, if it makes sense.

Andreas_D
+1  A: 

Check my answer for http://stackoverflow.com/questions/3442387/difference-between-java-interpreter-and-jvm

Yes there is difference difference between JVM and Java interpreter.

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

NOTE: copied my same answer from http://stackoverflow.com/questions/3442387/difference-between-java-interpreter-and-jvm

YoK