Handling unused imports in Eclipse

The following three ways can be used to fix the unused imports in Eclipse

  1. If you have a file or two with unused imports, open the file that has unused imports and use ctrl+shift+O, this automatically organizes the imports; removes unused and adds any missing imports
  2. Avoid unused imports by enabling the organize imports option in Window -> Preferences -> Java -> Editor -> Save Actions . Once this is done eclipse removes the imports automatically when a file is savedUnusedImport_SaveAction.jpg
  3. When there are already a large number of unused imports, all of them can be fixed at once by following the below steps
  • Open the Problems window in eclipse, select all the unused imports warnings
  • Right click on them and select the Quick Fix optionImport_QuickFix.jpg
  • Above step opens Quick Fix pop-window, click finishUnusedImport_SaveAction.jpg

 

2 thoughts on “Handling unused imports in Eclipse”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s