Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1512
  • Last Modified:

Compiler vs Interpreter

Hi, I understand that JVM comes with interpreter and advanced version comes with compiler. I need a clear cut difference between the functionalities of both ( compiler and Interpreter). If older version uses interpreter, what is the need to move on to JVM with Compilers. Which is advantageous, why?..what are the operations of both?.

2 Solutions
There are two main Java releases:
  Java Runtime Environment - allows running java applications and applets.
  Java Development Kit - allows compiling Java source code to bytecode. Also includes JRE.
Tommy BraasCommented:
Like StillUnAware lists, there are two different distributions available for JVMs. One that is purely a runtime environment (JRE), and one which includes developer tools (the JDK).

However, that has nothing to do with your question.

A JVM will execute byte code (which has previously been compiled by a Java compiler) in one of two mode: interpreted or compiled.

Interpreted mode is when the JVM executes the java byte code as java byte code.
Compiled mode is when the JVM has compiled the java byte code to native code such that execution of that code will be at, or near, native code speed.

The main difference between the two is obviously speed. A second difference, which is of importance for developers, is that when the code is interpreted line numbers are preserved and debugging is fairly straight forward. This is not the case for compiled mode. In compiled mode the line numbers are stripped, and this makes it harder to debug.


  In java languge when you write code  .all the code is in java .becos java is a platform independent language all your code need to be compiled  .Complier which comes with Java development kit  JDK compiles the java code in to classes .
 JVM is the run time envirnoment for java applications which should be there on every machine you want to run java application.Jvm converts the  java classes in to the machine language .

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

As I don't understand the answers given above I'll give my version:

The present JAVA (1.5.0_06) comes in ONE version that has an interpreter
to execute .class files and .jar files and an inbuilt HOTSPOT compiler
to re-compile critical code into machine language.
It is very hard to find out when the second comes into action,
but comparison with ultra-fast C-programs proves that the speed
of java programs is only a fraction slower, so it works!

The difference between the JRE (runtime version) and the JDK (development version)
is only the added source compiler, sources and some tools.

So, why the compiler? To build programs.
Why the interpreter? To run programs.
Why the hotspot compiler? To speed programs up.

Tommy BraasCommented:
>> So, why the compiler? To build programs.
Assuming you mean the javac compiler, for the same reasons that you compile regular source code files. To transform the textual representation of a program into a form that the machine can understand. The JVM is a Virtual Machine.

>> Why the interpreter? To run programs.

>> Why the hotspot compiler? To speed programs up.
Tommy BraasCommented:
Btw, I think our answers deserve more than a grade B.
orangehead911, read at Matthew 20:1-16 .....................


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now