Java Eclipse - 为现有项目设置 .classpath 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3343995/
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 - Setting .classpath file for existing project
提问by Greg
I have a java project. The working folder from someone else's Eclipse project (It was a Repast Simphony project I think).
我有一个java项目。来自其他人的 Eclipse 项目的工作文件夹(我认为这是一个 Repast Simphony 项目)。
In my eclipse I created a new Java project and told it to use the existing code. So it seems to have brought in all the code.
在我的 Eclipse 中,我创建了一个新的 Java 项目并告诉它使用现有代码。所以它似乎把所有的代码都带进来了。
However after loading the project I get this error:
但是在加载项目后,我收到此错误:
Project 'My Project' is missing required Java project: 'Weka 3-7'
It has a .classpath file with these contents:
它有一个包含以下内容的 .classpath 文件:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/Weka-3-7"/>
<classpathentry kind="output" path="bin"/>
</classpath>
What I've tried so far:
到目前为止我尝试过的:
I installed Weka 3-7. Then I updated the .classpath file to say the following and reloaded the project.
我安装了 Weka 3-7。然后我更新了 .classpath 文件以说明以下内容并重新加载项目。
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="C|/Program Files/Weka-3-7"/>
<classpathentry kind="output" path="bin"/>
</classpath>
But now I get the error message:
但现在我收到错误消息:
Project 'My Project' is missing required source folder: 'C|/Program Files/Weka-3-7'
Please help. I'm stuck.
请帮忙。我被困住了。
采纳答案by Kilian Foth
You want to use the context menu: My Project::(right mouse click)::Build Path::Configure Build path. This gives you the option to add/remove projects, Jars, source folders etc., what erver you need to provide those classes that your project references. You canget the same effect by hacking the .classpath
manually, but you have to know verywell what you're doing. Always use the frontend unless it absolutely can't do what you need.
您想使用上下文菜单:My Project::(鼠标右键单击)::Build Path::Configure Build path。这使您可以选择添加/删除项目、罐子、源文件夹等,您需要提供项目引用的那些类。您可以通过.classpath
手动破解来获得相同的效果,但您必须非常清楚自己在做什么。始终使用前端,除非它绝对不能满足您的需求。