Is there any way to automatically remove all unused imports (signaled with a warning) of a project with Eclipse IDE?
I just found the way. Right click on the desired package then Source
-> Organize Imports
.
Shortcut keys:
If you want to do this on whole project then inside project -->select src folder-->press Ctrl+Shift+O
You can direct use the shortcut by pressing Ctrl+Shift+O
I know this is a very old thread. I found this way very helpful for me:
Now every time you save your classes, eclipse will take care of removing the unused imports.
Remove all unused import in eclipse:
Right click on the desired package then Source->Organize Imports. Or You can direct use the shortcut by pressing Ctrl+Shift+O
Work perfectly.
Better way is just to add "save action" so when you save the project it will clear the unused import's and format the code as well if you like .
Go to Window > Preferences > Java > Editor > Save Actions
and pick what ever you want .