tags:

views:

117

answers:

4

Hi, Whenever I write a program in eclipse each line gets complied as go to next line.It shows compilation is done while writing he program only. Does it mean javac.exe file is run whenever you write a line of program? It debugging is much easier in Eclipse.

A: 

I believe the Eclipse IDE uses its own Java compiler.

Javac.exe is Sun's own official Java compiler, which I'm sure the Eclipse compiler borrows heavily from.

sdornan
FWIW, the Eclipse Compiler for Java is based entirely on the specification, it does not borrow any code from the Sun Java Compiler.
Wayne Beaton
A: 

You can turn it off in Project->Build Automatically. Eclipse is using it's own java compiler - eclipsec instead of javac.

peperg
Uh, no. `eclipsec` is not a java-compiler, it is the console-version of the eclipse launcher.
JesperE
True. JDT is the name
peperg
You can actually download ecj.jar from eclipse.org, ECJ is the part of JDT that provides the compilrer. It can be used separately from the command line (or otherwise). In fact, Tomcat uses ECJ to compile JSPs.
Wayne Beaton
+3  A: 

Eclipse actually has it's own compiler that is compiling your code as you type. It's not javac.exe but you can read more about it at the JDT page.

Terry Longrie
+9  A: 

Eclipse has his own compiler (JDT). It does not use the javac.exe compiler. The question is how does it achieve such short compilation times?

The internal data structure maintained by Eclipse for representing a Java program (AST) is the same data structure used by the JDT compiler. This sharing of data allows the compiler to run faster as it does not need to re-compile the whole program (or even the whole file) again.

Also, unlike javac.exe the JDT compiler resides inside Eclipse. It is not a separate process so it does not need to be loaded (by the operating system) the same way javac.exe does.

In addition to that (and this is true to all Java compilers), Java has dynamic linking. Each class is linked into the program when it is loaded during the execution of the program. This obviates the need for a linking phase at the end of compilation (a-la C/C++/C#). The linking phase is generally quite long as it processes the program as a whole (as opposed to compilation which is carried out on a a file-by-file basis). Thus, linking gets slower as the program grows. Techniques such as incremental linking have managed to mitigate this slow-down but not entirely.

Given that Java needs no (static) linking, you can get to a state where a Java program is ready to run much faster than in other (statically linked) languages.

Itay
The Sun Java compiler that you run using "javac.exe" can (I believe) also be run in the same JVM as an application. But the main reason that the JDT compiler is fast is because it is designed as an incremental compiler.
Stephen C
@Stephen javac.exe spawns a new instance of the JVM
Itay