Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I know what the JIT compiler is but how about why is it called that, it obviously catches exceptions Just in Time, but how and why should it be called this?

Sorry if this sounds a bit vague.

share|improve this question
I'd guess the actual "why" is "because JIT was a popular management buzz-phrase when Java started doing it, and they were trying to capitalize on that popularity." –  Jerry Coffin Jul 10 '12 at 5:19

5 Answers 5

up vote 21 down vote accepted

The Just-In-Time compiler doesn't have anything to do with exceptions. It refers to when code is compiled. Some languages, like Java, are translated from the language that you program in with your favorite editor into byte code. At runtime, some byte code might be further compiled into native code just prior to execution (hence the name, just-in-time). This is in contrast to some languages, like C, that are compiled into native machine code at the time when you invoke the compiler.

share|improve this answer
Thanks for that Thomas :) –  Sandeep Bansal Jul 9 '12 at 16:51
This term seems to have been coined in relation to Java byte code. What is peoples opinion on "scripting languages", those that are compiled at execution time? JIT, or something else? –  Paul Jul 9 '12 at 16:53
@Paul The JITing concept actually dates back to 1960 LISP. The JVM's JITer was derived from Sun's research on JITing small talk. Java's JITer is only notable for being the first one to go mainstream. –  Dan Neely Jul 9 '12 at 19:41
I was under the impression that part of the idea behind was that when that JIT compilation occurred, it could compile using processor-specific optimizations that wouldn't otherwise be possible since people have different models/steppings/etc. of microprocessor. –  Mark Allen Jul 9 '12 at 21:14
That's certainly possible, given adequate knowledge by the runtime of the machine it's running on. But, the primary advantage is that the intermediate code you write that is JITed by the runtime doesn't have to know what processor, or even what OS, it is being run on, so the same Java code could run on any computer from a PowerPC Mac with OS9 to a newer Intel OSX Mac to a Win7/Vista/XP/2000 machine to a quad-Xeon blade server running a LAMP/LAMJ stack. –  KeithS Jul 9 '12 at 22:46

The name comes from the "just in time" manufacturing methodology, wherein parts are delivered "just in time" to be installed. In manufacturing, it costs a lot of money to keep parts and supplies in inventory, and producing and delivering them as they're needed makes a process cheaper/more efficient.

The Java JIT compiler works in a way that's analogous to JIT manufacturing: instead of compiling code beforehand and keeping it around, it compiles code as its needed. This gives you short development cycles and immediate feedback of an interpreted language and the speed of a compiled language.

share|improve this answer
you don't really get the feedback of an interpreted language. You still need to compile .java to .class, and the only way to do that 100% reliably is to compile them all. Then you need to restart the JVM to load the modified .class files. –  kevin cline Jul 9 '12 at 18:50
@kevincline: It is possible to get more real-time feedback, even with Java; most Java debuggers allow you to execute small bits of code while at a breakpoint. But other languages do this much better: F# for example has an interactive REPL implemented with a JIT compiler. –  Daniel Pryden Nov 19 '12 at 20:20
@Daniel, great but what happens when I find the problem and want to fix it? Or when I just want to add the code to pass the next test? Those JVM restarts really take a toll. –  kevin cline Nov 19 '12 at 22:23
@kevincline: I agree, in the Java world it isn't very interactive. But that's a problem with the Java implementation, not with the approach of JIT compiling in general. For example, Visual Studio allows you to edit C# code while it's running and it re-JITs on the fly, so it can be done. –  Daniel Pryden Nov 20 '12 at 2:06

In .Net, say when a C# program is compiled, it is compiled into what is called "Microsoft intermediate language" (MSIL) Code, this code is machine independent. The MSIL Code is not directly executable as is. It must be converted (and optimized) to code that can be executed by the target OS (and CPU). That conversion occurs when you request a .Net program to run and is performed by the Just In Time (JIT) compiler, the JIT produces executable that is specific to OS (and CPU) you are running the application on. So the name Just In Time, indicates that the compilation from MSIL to native OS code only occurs when you request the code to execute. For more information see Compiling MSIL to Native Code.

share|improve this answer

Code is compiled when called. It is compiled just in time, or just before it is called if you prefer.

This apply to methods. If a method is never called, it is never compiled.

share|improve this answer

It doesn't have anything to do with exceptions.

The name reflects the fact that the software is not compiled into machine code until it is about to be executed. This allows you deploy an application to multiple computers and have machine-specific optimizations applied at runtime.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.