我的 Eclipse 副本不知道对象或字符串是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11796464/
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
My copy of Eclipse doesn't know what an object or a String is
提问by Annie
I have a copy of Eclipse Indigo on my mac. It was working fine until I imported a project I had made on a different computer. Now I get errors like "The type java.lang.Object cannot be resolved." and "String cannot be resolved to a type".
我的 Mac 上有一份 Eclipse Indigo。在我导入我在另一台计算机上制作的项目之前,它运行良好。现在我收到诸如“无法解析 java.lang.Object 类型”之类的错误。和“字符串无法解析为类型”。
Also, the computer I built it on had Java 7, while my slightly broken mac has Java 6, and won't update. I'm not sure, but I suspect this may be an issue.
此外,我构建它的计算机有 Java 7,而我稍微损坏的 mac 有 Java 6,并且不会更新。我不确定,但我怀疑这可能是一个问题。
What happened, and how do I fix it?
发生了什么,我该如何解决?
UPDATE
更新
I put what I think is the right JRE in the build path, but now when I run it, I get these errors:
我将我认为正确的 JRE 放在构建路径中,但是现在当我运行它时,出现以下错误:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Game : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access##代码##0(URLClassLoader.java:58)
at java.net.URLClassLoader.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
回答by Andrea Colleoni
Verify if you have a Runtime Enviroment in your build path.
验证您的构建路径中是否有运行时环境。
Object and String are at least in a JRE and the JRE must be referenced in the build path.
Object 和 String 至少在 JRE 中,并且必须在构建路径中引用 JRE。
If you create a new java project you'll find there by default, but it's there.
如果您创建一个新的 Java 项目,您会默认在那里找到,但它就在那里。
The project build path can be broken by moving the JRE or JDK, changing the JAVA_HOME environment variable or by misconfiguration of custom System libraries that refer to specific JREs.
移动 JRE 或 JDK、更改 JAVA_HOME 环境变量或引用特定 JRE 的自定义系统库的错误配置可能会破坏项目构建路径。
回答by Thorbj?rn Ravn Andersen
Your workspace is broken, notably the JRE you try to use.
您的工作区已损坏,尤其是您尝试使用的 JRE。
Fix the JRE used in Eclipse and the compiler settings, and then rebuild the project.
修复Eclipse中使用的JRE和编译器设置,然后重新构建项目。
回答by viveksinghggits
I got the very same error but after some digging I got to know about http://dev-answers.blogspot.de/2009/06/eclipse-build-errors-javalangobject.html
我得到了同样的错误,但经过一些挖掘,我了解了http://dev-answers.blogspot.de/2009/06/eclipse-build-errors-javalangobject.html
They are just saying to remove the JRE library and add Default System JRE Library.
他们只是说要删除 JRE 库并添加默认系统 JRE 库。
回答by melopsitaco
Check your classpath. It must point to your JDK.
检查您的类路径。它必须指向您的 JDK。