【转】 http://energykey.javaeye.com/blog/296380
The import *** cannot be resolved
搞了半天,遇到这个问题一般是从别的地方直接拷项目或拷源代码,
选择project-->clean后,问题得到解决。此选项的作用:将工程中的.class文件删除,同时重新编译工程,类似于jbuild中的rebuild
如果还不能解决,可以尝试删掉import,然后一个一个的手动导入【alt+/】
http://blog.sherifmansour.com/?p=207
I’m amazed at how many shortcuts or different ways there are of doing things in Eclipse.
Recently I kept hitting an issue of Eclipse not recognising my imports (even though they were there). I was always getting the message:
import ClassName cannot be resolved
.
Where ClassName was my imported class. I’m using the MyEclipse Workbench 5.5.1 on Eclipse 3.2. Here are a few tips on how you can fix this (some worked for me, some didn’t):
- ‘Clean’ Your Eclipse Project: Go to Project > Clean in Eclipse [This seems to work for me]
- Refresh your project folder (right click on your project > refresh)
- Re-build your project
- Clean your builds (If using Ant or Maven – clean your builds)
- Recreate your project in Eclipse
- ‘Switch’ Workspace – then Switch back (Eg Change to Debug, then switch back to Java)
- ‘Switch’ Workspace – then Switch back (Eg Change to Debug, then switch back to Java)
- Remove and re-add your JRE:
1. Right Click on your project > properties
2. Click on the Libraries tab
3. Click on the JRE
4. Click remove, then OK
5. Repeat 1-3 again, but add the JRE again