无法解析类型 java.lang.object - Eclipse 构建路径不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25337182/
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.lang.object cannot be resolved - Eclipse buildpath not working
提问by user2260199
I'm having a problem with Eclipse on by Mac OSX Mountain Lion. I have recently installed Android SDK and in my java projects I get the following message:
我在 Mac OSX Mountain Lion 上运行 Eclipse 时遇到问题。我最近安装了 Android SDK,在我的 Java 项目中,我收到以下消息:
The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
无法解析 java.lang.Object 类型。它是从所需的 .class 文件间接引用的
Reading about this issue, it would seem that I do not have a valid JRE defined in the build path of my project. Checking the project's build path with Properties > Java Build Path > Libraries I see that The JRE System Library has a red cross next to it. However when I click Add Library... > JRE System Library I get the message:
阅读有关此问题的信息,似乎我的项目的构建路径中没有定义有效的 JRE。使用 Properties > Java Build Path > Libraries 检查项目的构建路径,我看到 JRE 系统库旁边有一个红叉。但是,当我单击添加库... > JRE 系统库时,我收到消息:
An error has occured. See error log for more details. java.lang.NullPointerException
出现错误。有关更多详细信息,请参阅错误日志。java.lang.NullPointerException
I then try clicking Eclipse > Preferences > Java > Installed JREs and see an empty list. I try to Add... a Standard VM but I cannot find the location of my JRE. /Library/Java/JavaVirtualMachines/ is empty and /System/Library/Frameworks/JavaVM.framework does not exist.
然后我尝试单击 Eclipse > Preferences > Java > Installed JREs 并看到一个空列表。我尝试添加...一个标准 VM,但找不到 JRE 的位置。/Library/Java/JavaVirtualMachines/ 为空且 /System/Library/Frameworks/JavaVM.framework 不存在。
Does anyone know how I might fix this problem?
有谁知道我如何解决这个问题?
回答by VonC
You can follow instruction to install a JDL (which includes a JRE) for Mac here.
您可以在此处按照说明为 Mac 安装 JDL(包括 JRE)。
Depending on your processor, the downloaded file has one of the following names:
jdk-8uversion-macosx-amd64.dmg
jdk-8uversion-macosx-x64.dmg
Where version is 6 or later.
- Download the file.
- Before the file can be downloaded, you must accept the license agreement.
- From either the Downloads window of the browser, or from the file browser, double click the .dmg file to launch it.
A Finder window appears containing an icon of an open box and the name of the .pkg file.
根据您的处理器,下载的文件具有以下名称之一:
jdk-8uversion-macosx-amd64.dmg
jdk-8uversion-macosx-x64.dmg
版本为 6 或更高版本。
- 下载文件。
- 在下载文件之前,您必须接受许可协议。
- 从浏览器的“下载”窗口或文件浏览器,双击 .dmg 文件以启动它。
出现一个 Finder 窗口,其中包含一个打开框的图标和 .pkg 文件的名称。
- Double click the package icon to launch the Install app.
- 双击包图标以启动安装应用程序。
回答by jyothiv
This worked for me :
这对我有用:
- Right click on your project -> Build Path -> Configure Build Path
- Go to 'Libraries' tab
- Click on 'Add Library' -> JRE System Library -> Next -> Workspace default JRE (or you can add Alternate JRE) -> Finish
- 右键单击您的项目 -> 构建路径 -> 配置构建路径
- 转到“库”选项卡
- 单击“添加库”-> JRE 系统库-> 下一步-> 工作区默认 JRE(或者您可以添加备用 JRE)-> 完成
回答by JamesB
Right Button in the Project:Build Path >> Configure Build Path >> Click JRE System Library >> Remove
项目中右键:构建路径>>配置构建路径>>点击JRE系统库>>删除
Then click:Add Library >> JRE System Library >> Next >> Installed JREs >> Select JRE >> Ok >> Finish >> Apply
然后点击:添加库>>JRE系统库>>下一步>>安装的JREs>>选择JRE>>确定>>完成>>应用