无法解析 java.util.Map$Entry 类型。它是从所需的 .class 文件间接引用的
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24110620/
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
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files
提问by ashwin1907
I am writing a simple Java program on Eclipse.
我正在 Eclipse 上编写一个简单的 Java 程序。
import java.util.HashMap;
public class Demo {
public static void main(String[] args) {
HashMap<String, String> hash = new HashMap();
}
}
The above program generates the following errors.
上述程序产生以下错误。
- The project was not built since its build path is incomplete. Cannot find the class file for java.util.Map$Entry. Fix the build path then try building this project.
- The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files.
- 该项目未构建,因为其构建路径不完整。找不到 java.util.Map$Entry 的类文件。修复构建路径,然后尝试构建此项目。
- 无法解析 java.util.Map$Entry 类型。它是从所需的 .class 文件间接引用的。
I searched over the internet almost everywhere, but I was not able to correct this.
我几乎到处都在互联网上搜索,但我无法纠正这个问题。
I have installed Java SE 8u5 (JDK) (http://www.oracle.com/technetwork/java/javase/downloads/index.html?ssSourceSiteId=otnjp)
我已经安装了 Java SE 8u5 (JDK) ( http://www.oracle.com/technetwork/java/javase/downloads/index.html?ssSourceSiteId=otnjp)
- Windows -> Preferences -> Installed JREs shows
- Windows -> Preferences -> Installed JREs 显示
a) jdk C:\Program Files\Java\jdk
a) jdk C:\Program Files\Java\jdk
- Project -> Build Path -> Libraries shows
- 项目 -> 构建路径 -> 库显示
a) JRE system library (jdk)
a) JRE 系统库(jdk)
b) JRE system library (jre8)
b) JRE 系统库 (jre8)
Please somebody help me.
请有人帮助我。
EDIT:Changing Eclipse version from Helios to Juno solved the problem!
编辑:将 Eclipse 版本从 Helios 更改为 Juno 解决了问题!
回答by Wyzard
I've seen occasional problems with Eclipse forgetting that built-in classes (including Object
and String
) exist. The way I've resolved them is to:
我看到 Eclipse 偶尔会出现忘记内置类(包括Object
和String
)存在的问题。我解决它们的方法是:
- On the Project menu, turn off "Build Automatically"
- Quit and restart Eclipse
- On the Project menu, choose "Clean…" and clean all projects
- Turn "Build Automatically" back on and let it rebuild everything.
- 在“项目”菜单上,关闭“自动构建”
- 退出并重新启动 Eclipse
- 在“项目”菜单上,选择“清理...”并清理所有项目
- 重新打开“自动构建”并让它重建所有内容。
This seems to make Eclipse forget whatever incorrect cached information it had about the available classes.
这似乎使 Eclipse 忘记了关于可用类的任何不正确的缓存信息。