Accepted answer

preferences->java->editor->save actions->configure...

you can configure the removal of unused imports when saving from the unnecessary code tab.

adding imports would normally be done as you are writing the code otherwise it won't compile.

this is how it looks like: enter image description here


yes, it is called save actions. there you can enable several thing should be done when saving a file.


either: <project>->properties->java editor->save actions


windows->preferences->java->editor->save actions


doing while saving is great, but if you already have lots of files that need it applied to you can also select the package in the package explorer and go to source->organise imports it will apply to each file below that package.

you may be doing this already, i just wanted to make it clear that it can be applied to many files as can source->format.

Related Query

More Query from same tag