Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How JIT (Just In Time Compiler) Works

 
Dhiren Lodhia
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic