“此编译单元不在 java 项目的构建路径上”-Eclipse

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10731984/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:04:54  来源:igfitidea点击:

"This compilation unit is not on the build path of a java project" -Eclipse

eclipsemercurialautocomplete

提问by Deepak Mani

I am new to the eclipse environment. I clone my project from the repository(Hg) by New->Project->Mercurial->Clone existing project. Here my problem is "This compilation unit is not on the build path of a java project" message comes when I editing the coding. Auto completion not working. Kindly let me know how solve this problem...

我是 eclipse 环境的新手。我通过 New->Project->Mercurial->Clone existing project 从存储库(Hg)克隆我的项目。这里我的问题是“此编译单元不在 java 项目的构建路径上”消息在我编辑编码时出现。自动完成不起作用。请让我知道如何解决这个问题...

Note: I searched in google as well as in stackoverflow. But still I am not clear in that.

注意:我在 google 和 stackoverflow 中进行了搜索。但我仍然不清楚。

回答by Jaiprakash

I had this problem in Eclipse on Windows 7 as well. The solution is Go to Project-> right Click-> Select Properties -> project Facets -> modify the java version for your JDK version you are using. Please note, if the JDK version of the project is higher, say, 1.5 and your project setting is jdk 1.4, then it will not work. Vice versa will work.

我在 Windows 7 上的 Eclipse 中也遇到了这个问题。解决方法是转到项目-> 右键单击​​-> 选择属性-> 项目构面-> 修改您正在使用的JDK 版本的java 版本。请注意,如果项目的 JDK 版本更高,例如 1.5,并且您的项目设置为 jdk 1.4,那么它将不起作用。反之亦然。

回答by Arvind Sridharan

Right click your project, select properties. On the left side select Java Build Path. Go to the Libraries tab and select the JRE System library. On the right side, click the edit option. Select the Alternate JRE radio button. See if the JDK you have installed is present in your drop down and select it. This should fix your problem.

右键单击您的项目,选择属性。在左侧选择 Java Build Path。转至库选项卡并选择 JRE 系统库。在右侧,单击编辑选项。选择备用 JRE 单选按钮。查看您安装的 JDK 是否存在于您的下拉列表中并选择它。这应该可以解决您的问题。