Tutorial :Is the statement “All Java byte code interpreter are JVMs but all JVMs are not Java interpreters” true? [closed]


Is the statement "All Java byte code interpreter are JVMs but all JVMs are not Java interpreters" true?

I am really confused as a JVM is used for running Java program only. Or can it do anything else as well?


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.


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


Yes, there is a 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 a JVM.



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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »