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??
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).
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 ]