Search code examples
javaeclipsecompiler-warningsjavac

The Compiler Warning shows up even when the import it shows as unused, is actually not being used in the class


I usually prefer keeping the code clean from all the Compiler warnings- be it unused import, unused variable, unused private methods, unnecessary suppress, unchecked, unnecessary cast, unnecessary condition (always be true or false), unannotated overridden methods or reference to deprecated class/methods.

But this particular warning keeps showing up even when the import it shows as unused, is actually not being used in the class(at least not anymore). I need to know how to get that fixed.

I did try cleaning up the Project, Organizing the Imports, Building the project and also tried restarting the eclipse.

But what fixes the issue is when I delete the class and create the same class over again. That's really not a solution. There has to be quicker way to do that without having to do a re-work.

Any thoughts?

SCREENSHOT OF THE CLASS FROM THE ECLIPSE IDE


Solution

  • Using Eclipse, select Project->Properties then select Java Editor->Save Actions, check "Additional actions", click on "Configure" and then under "Unnecessary code" be sure to select "Remove unused imports"