Eclipse 无法识别字符串和类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13422683/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse not recognizing Strings and Classes
提问by McShpoochen
I've had a project built by eclipse saved, then my computer sort of died. When I fixed it and reformatted I redownloaded eclipse and such. Actually, when I press on "eclipse.exe" it shows me the eclipse juno icon but the window's name is Java- ADT and and it looks kind of differently. I've installed the ADT Plugin and all the Android APIs but when I import my project, when it opens the classes lets say, it doesn't recognize anything. I mean, Strings, classes, imports, android, nothing.
我保存了一个由 eclipse 构建的项目,然后我的电脑就死了。当我修复它并重新格式化时,我重新下载了 eclipse 等。实际上,当我按下“eclipse.exe”时,它会向我显示 eclipse juno 图标,但该窗口的名称是 Java-ADT,而且看起来有点不同。我已经安装了 ADT 插件和所有 Android API,但是当我导入我的项目时,当它打开类时,可以说,它无法识别任何东西。我的意思是,字符串、类、导入、android,什么都没有。
It says: The import android cannot be resolved. Or: String cannot be resolved as a type.
它说:无法解析导入android。或:字符串无法解析为类型。
Does anyone have an idea?
有没有人有想法?
BTW: XML works fine.
顺便说一句:XML 工作正常。
回答by Yogendra Singh
Go to Menu(Windows) ->Preferences -> Java -> Installed JREs
and make sure your JREs are available and appropriate one is selected. If not (I hope, that's the case), add the libraries by using Add
button in the right side and browsing the JRE installed location.
转到Menu(Windows) ->Preferences -> Java -> Installed JREs
并确保您的 JRE 可用并选择了合适的 JRE。如果没有(我希望是这样),请使用Add
右侧的按钮并浏览 JRE 安装位置来添加库。
In addition to above step, go to Right Click(project) -> properties -> Java Build Path -> libraries
. Again make sure, right libraries and Jars are selected there and valid. If not, add/correct them.
除上述步骤外,转到Right Click(project) -> properties -> Java Build Path -> libraries
。再次确保,在那里选择了正确的库和罐子并且有效。如果没有,请添加/更正它们。
回答by Mordechai
Redownload the JDK, this will automatically update Eclipse.
重新下载JDK,这会自动更新Eclipse。