Eclipse - Setting .classpath file for existing project

Greg picture Greg · Jul 27, 2010 · Viewed 36.1k times · Source

I have a java project. The working folder from someone else's Eclipse project (It was a Repast Simphony project I think).

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.

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:

<?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.

<?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.

Answer

Kilian Foth picture Kilian Foth · Jul 27, 2010

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 can get the same effect by hacking the .classpath manually, but you have to know very well what you're doing. Always use the frontend unless it absolutely can't do what you need.