A few days ago my eclipse stopped being able to auto import classes. So usually when I have a class I'm using, like BufferedReader, that I need to import I simply hit ctrl+shift+O and the imports magically appear. But now, basic imports like List or Scanner just sit there all squiggly and red. I have the 1.6JRE included as part of my project, and when I manually import them they will then work.
This is a huge annoyance and time sink now. I'm open to any suggestions to fix the problem.
As you type a class name, press Ctrl+Space to bring up Eclipse's autocomplete. Once you press Enter to select it, Eclipse will automatically add an import for the class.
Go to Preferences » Java » Editor » Content Assist » Advanced. Make sure Other Java Proposals is ticked/checked. If that does not work simply close the project and reopen it.
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 the Java file.
I have seen this behavior before. Sometimes just closing and reopening Eclipse resolves it. Sometimes I have had to recreate the project from the source, which can be painful if you have a lot of dependencies and you're not using Maven. You should also do a File/Refresh at the top level to make sure you're in sync with the filesystem
Try restoring the default options in 'Windows > Preferences > Java > Editor > Content Assist > Advanced'.
If it does not work, try to create a new workspace and it may solve your problem
Hope it helps!
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