Sarmun
Sarmun

Reputation: 2408

Eclipse compiling problem

Is there a way to set Eclipse report compile errors same as javac?

I stumble upon few cases where something is working in eclipse, and cannot be compiled with javac. I understand that eclipse uses ECJ and that cannot be changed, but can it anywhere be set that everything that cannot compile with javac be a compile error in Eclipse? (since there are few things that you can make compile errors in Eclipse even if they are ok)

Examples are from @SuiteClasses({A.class,B.class,}) (last comma is the problem), to subtle generic problems that I fully don't understand.

Upvotes: 3

Views: 1747

Answers (4)

ameed
ameed

Reputation: 1170

If you want, you can change your Eclipse preferences to more restrictive javac-esque equivalents. This will produce warnings or errors for what you define when compiling--you can even define errors/warnings for everything!!

Upvotes: 0

Deepak Azad
Deepak Azad

Reputation: 7923

Both, Eclipse Compiler for Java (ECJ) and Javac, are based on the Java Language Specification (JLS) and hence are supposed to report the same errors.

However there are cases where where the behavior differs. At times the reason is bugs as is the case in any large piece of software, and at times the JLS is a bit ambiguous causing it to be interpreted slightly differently by both compilers. At times ECJ is at fault and at times Javac is at fault.

Upvotes: 0

Vineet Reynolds
Vineet Reynolds

Reputation: 76719

Eclipse uses ECJ for compilation via the Java Builder that is responsible for compiling and indexing all Java source files in order to make incremental compilation easier (making it easier for errors to be reported), apart from aiding refactoring and search operations.

ECJ happens to be the default and only compiler used by the Java builder; the compiler used cannot be configured. One cannot change it. However, you could attempt to add your own builder that uses an Ant build script relying on the javac compiler of the Sun JDK.

Upvotes: 2

daveb
daveb

Reputation: 76301

You can make eclipse build use ant, that will in turn use javac.

Upvotes: 1

Related Questions