• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interpreter  RSS feed

 
Niranjan Prasad
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between JVM and Interpreter?
Does Interpreter converts the .class file to .exe and gives it to the processor?If so what is JVM doing?
Is true that JVM and Interpreter are same?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JVM is an interpreter for Java byte code. It reads the byte code and executes the instructions.

That's the general principle, but in practice it's a bit more complicated. In order to make Java programs run faster, the JVM calls the JIT (Just In Time) compiler to convert the Java byte code of frequently used pieces of code into native machine instructions, so that it doesn't have to interpret the byte code every time that piece of code is executed.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The term "interpreter" has a much more general meaning than what is discussed here. Typically, an "interpreter" is an option that can be used instead of a "compiler". An interpreter differs from a compiler in that it "interprets" the commands into binary code that the computer unsterstands as the program runs. This means that every time you run a program, the interpreter needs to change the commands into so-called "native code". On the other hand, a compiler converts the program into native code once when it is compiled. Then when you run the program, the native code is run directly; there is no intermediate interpretting step.

These two options have their advantages and disadvantages. Compiling code takes extra time when you are developing and testing software. Interpreting code takes more time when it is run. There are other trade offs, but these are the primary two, in my opinion.

Layne
 
Naveen Vooka
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interpreter: An interpreter is a computer program that executes other programs. This is in contrast to a compiler which does not execute its input program (the source code) but translates it into executable machine code (also called object code) which is output to a file for later execution. It may be possible to execute the same source code either directly by an interpreter or by compiling it and then executing the machine code produced.

Java Virtual Machine. An abstract computing machine, or virtual machine, JVM is a platform-independent programming language that converts Java bytecode into machine language and executes it. Most programming languages compile source code directly into machine code that is designed to run on a specific microprocessor architecture or operating system, such as Windows or UNIX. A JVM -- a machine within a machine -- mimics a real Java processor, enabling Java bytecode to be executed as actions or operating system calls on any processor regardless of the operating system. For example, establishing a socket connection from a workstation to a remote machine

--------------
Naveen Vooka
www.devsquare.com
DevSquare - Online Application Development
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!