aspose file tools*
The moose likes Beginning Java and the fly likes java is  interpreter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java is  interpreter" Watch "java is  interpreter" New topic
Author

java is interpreter

ramchander yshetti
Ranch Hand

Joined: Apr 22, 2006
Posts: 97
hai,

please clear for me interpreted or JIT which one is first
when my program is first executed.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
What to compile and when is up the the JVM designer. Most modern JVMs have some algorithm to decide when it's worth compiling a chunk of code, perhaps when it's been executed a few times or maybe looks like it will be executed a lot. The "Just In Time" part means they don't go overboard compiling everything before they need it, though I suppose they could if they wanted to.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ajay Divakaran
Greenhorn

Joined: Jul 08, 2007
Posts: 22
java is a compiler as well as an interpreter.
When you finish creating your .java file and invoke
javac <classname>.java
Your .java code is compiled and converted to bytecode
and when you invoke
java <classname>
The java interpreter is called to convert your bytecode to machine code
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The java interpreter is called to convert your bytecode to machine code


The interpreter / JVM may or may not do this entirely at its own pleasure. You can disable the JIT compiler at the command line, but I don't think you can tell it anything else.

I find what a real interpreter does hard to put into words. The interpreter part of the JVM carries out the bytecode instructions much the way a cook follows a recipe. It doesn't convert bytecode to anything. It looks at one bytecode instruction at a time, says "I know what that means!" and does it.

The compiler part of the JVM can generate machine code from bytecode if it wants to. I guess it builds a robot that can follow part of exactly one recipe very, very quickly.
Shrikanth Nekkanti
Ranch Hand

Joined: Jul 12, 2007
Posts: 48
When you save your file with .java extension and when you compile it using javac classname.java you will get classname.class file which contains byte understandable by JVM
Interpreter is a module in JVM which converts bytecode into machine executable code.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42910
    
  68
Originally posted by Shrikanth kumar:
Interpreter is a module in JVM which converts bytecode into machine executable code.


As Stan said, this is not quite correct. An interpreter doesn't so much produce executable code (that's a compiler's job), but perform the steps needed to execute the bytecode. The native code that is the equivalent of the bytecode is not generated in the process.
Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 504

try this links
JVM
Again JVM


Millions saw the apple fall, but Newton asked why.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
Please don't resurrect a 1-year old thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java is interpreter