stackoverflowuser2010
stackoverflowuser2010

Reputation: 40969

Why does Eclipse warn about Java "unused variables" but javac does not?

For the same code, Eclipse shows warnings about unused variables, but compiling with "javac" (v1.6) does not. Does Eclipse use a different compiler or parser? How can I get javac to show the same warnings?

Upvotes: 4

Views: 3501

Answers (5)

ring bearer
ring bearer

Reputation: 20803

Quote from JDT core (Eclipse's editor infrastructure)

JDT Core is the Java infrastructure of the Java IDE. It includes:

An incremental Java compiler. Implemented as an Eclipse builder, it is based on technology evolved from VisualAge for Java compiler. In particular, it allows to run and debug code which still contains unresolved errors.

It is the incremental Java compiler that shows the warning.

There are no ways to enable that warning in Sun/Oracle javac

Upvotes: 6

vacuum
vacuum

Reputation: 2273

From javadoc:

-Xlint Enable all recommended warnings. In this release, all available warnings are recommended.

And yes, eclispe use own compiler

Upvotes: 3

tjg184
tjg184

Reputation: 4686

This is part of the validation in eclipse. If you wanted your own rules similar to what eclipse does, you could use something like PMD.

http://pmd.sourceforge.net/rules/unusedcode.html

Upvotes: 2

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272687

Eclipse uses its own compiler. You can enable/disable various messages by going to Window->Preferences->Java->Compiler->Errors/Warnings.

Upvotes: 6

kundan bora
kundan bora

Reputation: 3889

This is Eclipse own functionality.

Upvotes: 2

Related Questions