How to remove unused imports from Eclipse
Solution 1:
I just found the way. Right click on the desired package then Source
-> Organize Imports
.
Shortcut keys:
- Windows: Ctrl + Shift + O
- Mac: Cmd + Shift + O
Solution 2:
You can direct use the shortcut by pressing Ctrl+Shift+O
Solution 3:
I know this is a very old thread. I found this way very helpful for me:
- Go to Window → Preferences → Java → Editor → Save Actions.
- Check the option "Perform the selected actions on save".
- Check the option "Organize imports".
Now every time you save your classes, eclipse will take care of removing the unused imports.
Solution 4:
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.