Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse - Setting .classpath file for existing project

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.

like image 799
Greg Avatar asked Jul 27 '10 13:07

Greg


People also ask

Do we need to commit .classpath file?

classpath file is make sure you don't reference files outside of your project. Eclipse stores the location of these files with a full filepath, and you would need to make sure other developers had those files in exactly the same place.

How .classpath file is generated?

classpath file is created in the project's root directory. If you created the project on an existing code-base, eclim will attempt to setup the . classpath file with any source code directories or libraries in the project. Regardless of the state of your project you will at some point need to update the classpath.

What is the classpath of my project?

The . classpath maintains the project's source and target references for Java compilation and compressed file or project dependencies. This configuration is maintained through the Java Build Path page in the project's properties.


1 Answers

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.

like image 140
Kilian Foth Avatar answered Sep 21 '22 23:09

Kilian Foth