This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes How JIT (Just In Time Compiler) Works Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How JIT (Just In Time Compiler) Works" Watch "How JIT (Just In Time Compiler) Works" New topic
Author

How JIT (Just In Time Compiler) Works

Dhiren Lodhia
Greenhorn

Joined: Mar 05, 2008
Posts: 14
Hi all,

We all know that there are two steps of running a java program

[1] convert your .java file to bytecode using javac [called compilation] so you get .class file
[2] run your .class file using java [called interpretation] so you get your output.

I know that .java file is compiled only once using javac & we get .class file i.e bytecode i agree

Now when we want to run the file JRE which has java will run the file and give us the output.

now earlier days in java (may be in jdk1.1 or so) JRE used to interpret the byte code line by line and execute
which had one problem of performance compared to compiled languages like c & c++

so to solve that problem and improve performance now a days JRE includes apart from interpreter also one compiler called JIT(also called HotSpot Compiler) which compiles the byte code(instead of interpreting to native platform) hence improving performance.

first of all is my above understanding correct so far about JIT??

then i have a question?
this directly means that now a days a JRE is capable of both interpreting as well as compiling the byte code.
so question is how it will decide compile or interpret ?

Please s Note when i say compiling the byte code i do know we actually compile .java file ony once,i am not saying compiling .class file with javac again [its not possible] i am saying it in context of running the .class file.

i hope i have made my self clear!!

Please let me know if so far things are correct .

Thanks in advance


Dhiren Lodhia
SCJP 5.0 (93%)
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3432
    
  12
This is a good place to start.

That page was linked to from here which should give you all the information any sane person would ever want about the Java HotSpot Virtual Machine.


Joanne
 
wood burning stoves
 
subject: How JIT (Just In Time Compiler) Works
 
Similar Threads
jit vs. interpreter
Stupid question?
JIT Question
What does JIT compiler do ?
is there a EXE file in java ?