How to remove unused imports from Eclipse

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:

  1. Go to Window → Preferences → Java → Editor → Save Actions.
  2. Check the option "Perform the selected actions on save".
  3. Check the option "Organize imports".

Now every time you save your classes, eclipse will take care of removing the unused imports.


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

Tags:

Eclipse