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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt regarding java compilation " Watch "Doubt regarding java compilation " New topic
Author

Doubt regarding java compilation

pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
guys,

say you have a source code(java)

Step1: source code gets converted to byte code(.class file) when compiled

Step2: that Bytecode is taken by the JVM and intepreted to get the output

Step3: Then when will the JIT come into picture because the intepretation does not happen for the entire Bytecode all at once i mean it takes the bytecode chunk by chunk but in case of JIT the entire thing has to be taken i guess??

difference between java compiler and JIT?
can anyone clear this doubt??
Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
The JIT compiler changes the behavior of the JVM by compiling the Java bytecode into the native platform code. And, since the native code can be run directly on the underlying platform, there can be significant speed improvement.

Also, the calls from the JVM to the native operating system are intercepted by the JIT compiler which then generates the native code to be passed to the native OS. Successive calls result in the native code being executed. Therefore, the compilation only occurs once (the first time a call is made).


SCJP 1.4 85%
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14266
    
  21

The JIT compiler is part of the JVM. It does its job at runtime - when your Java bytecode is running. The JVM keeps track of which methods and statements are being executed in your program, and when it notices that it's running the same bytecode more often, it calls the JIT to compile that piece of bytecode to native machine code for the platform the program is running on. Running native machine code is faster than interpreting and running bytecode instructions.

Note the name: JIT stands for Just In Time - i.e., the JIT compiler converts your bytecode to native machine code at the moment it's needed.
[ November 17, 2007: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
is it like interpretation happens only for unique bytecode elements and repeated segments in bytecode get JIT treatment?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt regarding java compilation