On a generated project I get 100s of warnings caused by unused imports and such things. Can I bulk cleanup those imports for all files?
Eclipse provide a shortcut CTRL + SHIFT + O, this shortcut command will remove all those unused imports from your code file.
Here are the steps to organising imports whenever you save: Go to Window > Preferences > Java > Editor > Save Actions. Select Perform the selected actions on save (off by default). Ensure that Organize imports is selected (on by default).
1) Go to the line of unused import, press Ctrl + 1, which is an Eclipse shortcut of a quick fix. This will show a drop-down menu to fix this error and one of them will be "remove unused imports." It will remove that import statement from Java file.
It's better to use the “Organize Imports” feature of Eclipse IDE to remove multiple or all unused imports statement. For using this from Menu, Select Source → Organize Imports. This will remove all unused imports from that Java file.
In package explorer right click on the root package of your project and choose source -> organize imports
CTRL-SHIFT-O will do this on a file by file basis in eclipse, if you want to do an entire project, you might need to use something like jalopy. There is a jalopy eclipse plugin, but I'm not sure if it will do an entire project at one time or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With