Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How JIT (Just In Time Compiler) Works  RSS feed

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
Posts: 3742
  • 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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!