\"Clean...\" (if \"Project\" > \"Build Automatically\" is checked)" />
开发者

How come my eclipse editor shows no error but when I try to run the file, it shows "cannot be resolved to a type" error?

as stated in开发者_StackOverflow社区 the title.


In Eclipse, try "Project" > "Clean..." (if "Project" > "Build Automatically" is checked)

This should force Eclipse to rebuild your app and it should catch the error.


The Eclipse incremental compiler sometimes gets 'confused' so try a 'Project -> Clean... -> Clean All Projects'. This will do a complete rebuild of your workspace. After that all weird compiler problems disappear.

But in general it would be better to have more information about your problem (as stated by the others)


Eclipse compilation is sometimes not very obvious. Check in your Menu -> Project -> Build Automatically.

If this is set then with every edit eclipse builds the project (This is okay for smaller projects but for bigger projects with a few 1000s of files this can be a problem).

So in your case it is perfectly possible that Eclipse has not done any building as you type and deferred it until the run stage where eclipse has to build classes.

If this is not your case, it might be one of those eclipse oddities, a few restarts of eclipse, general cursing and a cup of coffee should do !


Eclipse saves much metadatas about projects. If this medatas are incorrect, Eclipse shows sometimes errors which not exists! Try to start your Eclipse with the -clean parameter, e.g.:

eclipse.exe -clean

That will forced Eclipse to collect the metadata again!


thanks to all of you for your kindness. I've finally solved my problem. I've tried all the methods stated above but to no avail (because I didn't provide enough details, sorry). I found that because my current project is dependent on another project, and somehow eclipse doesn't build the dependency of the project automatically. So for anybody facing the same problem as I was, each time you make changes to the dependencies of your project, make sure the changes is propagated to all other projects that are dependent on it. Furthermore, it seems like eclipse's editor uses different dependency view from the compiler. That's why it doesn't show any error while the compiler failed to compile due to dependency issues.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜