Eclipse and IntelliJ IDEA take a slightly different perspective of the process of compilation. In particular, Eclipse comes with its own compiler--Eclipse Compiler for Java or ECJ for short. ECJ differs from classic javac primarily because it allows for incremental builds from within the Eclipse IDE. In other words, all code is compiled as soon as you finish typing.

Icon

Note: Availability of ECJ enables Eclipse also to generate binaries out of code that wouldn't compile with javac. The produced binary works well as long as broken instructions are not reached during a session. In addition, ECJ allows developers to write, compile, and run Java code in Eclipse without even installing the Java SDK.

Compiling Projects in IntelliJ IDEA

By default, IntelliJ IDEA compiles files on demand that is when you run the application or explicitly invoke the Make action. The rationale behind this choice is to preserve system resources for other tasks that can be more important at the moment.

The compilation in IntelliJ occurs through javac but the entire process is still guaranteed to incremental and then as fast as possible. IntelliJ IDEA, in fact, keeps track of the dependencies existing between source files and recompiles only files that have been modified. Files with compilation errors are highlighted, and so are the folders where such files are contained.

To see a list of all files with compilation errors, from the drop-down list at the top of the project explorer window you select Problems, as shown below.

Note that IntelliJ IDEA constantly performs background code analysis on files with errors and removes the red highlighting automatically as soon as you fix errors.

Compiling on Every Save

A feature of Eclipse that sometimes developers seem to miss in IntelliJ IDEA is compilation on every save. This feature does exist in IntelliJ IDEA, except that it is disabled by default. You can enable it from the Settings dialog box, under the Compiler tab. All you do is checking the Make project automatically option.

Compiling Code with Errors

IntelliJ IDEA also bundles ECJ. You can instruct IntelliJ to use ECJ instead of javac from the Settings dialog.

Once you have selected the Eclipse compiler to compile your code, you can also enable compilation with errors in IntelliJ IDEA. You just check the Proceed on errors option for the Eclipse compiler.