57

I have a directory called c:\RemoteSrc . Under this there are 3 directories which are currently source folders (I think? the icon is an open folder with a little orange grid in it) in my Eclipse project. I have dropped a new directory under c:\RemoteSrc which I also want to add to my project.

BUT

If I right click on my project and go "Build Path..." -> "Link Source" and try to add it it tells me "Folder already exists with a different case". Yes i KNOW that the folder already exists THATS WHY IM TRYING TO ADD IT.

2
  • And if from the Build Path config I hit "Add Folder" then the new folder doesn't show up in the tree there. Why not??? Commented May 14, 2010 at 23:28
  • If you can post your .classpath and .project it may help clarify the issue Commented May 14, 2010 at 23:37

7 Answers 7

55

I think all you need to do is refresh the project. Eclipse does not automatically pick up folders (or files) dropped into it's project directory.

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you soooo much! As simple as this I would not believe it.
Closing and opening the project didn't work either for me. I had to explicitly refresh. Thanks for the answer!
I think this is one of the cases where a better worded error message would have spared a people for a lot of frustration. Even after reading this answer it took me 10 minutes before realizing Eclipse was talking about the destination folder existing.
I had no idea it was so easy: Right-click project, click refresh. Now all my new files from my latest git pull show up in the project.
Hmmm... maybe my problem was different. I had to right click the folder and choose Build Path->Include.
5

A screen capture might help, but if the GUI is un-cooperative, you can:

  • close Eclipse
  • open the .classpath file which defines your project (it may be located in your workspace)
  • see if you can define a new classpathentry of kind "src": this is not the easy method, but that may give you an idea why the GUI refuses to define the same entry.

4 Comments

Almost worked. I did that and hit refresh. Now i get an error "XML format error in .classpath file of project 'xxx': Bad format'
If you correctly added it, there should be a corresponding entry in the .project file as well. Sometimes when you link a folder and then remove it the link still exists. Look at your project and see if it is still there.
@evilfred: might be some quotes or '>' missing, or a unix-eol-style saved with a windows-eol-style.
Ah ok. I took it out of the .classpath, hit Refresh, then I was able to "Add Folder" it. This isn't exactly intuitive.
5

For Linked Sources, you should have something like the following in your .classpath

<classpathentry kind="src" path="module_name"/>

With a corresponding matching entry (within <linkedResources>)in your .project

<link>
  <name>module_name</name>
  <type>2</type>
  <location>path/to/your/module</location>
</link>

NOTE: Removing a linked project doesn't necessarily remove it from the project.

2 Comments

Thank you that makes sense. I just wish that Eclipse had a more intuitive GUI :)
I personally think NetBean's interface is pretty good. Much of the configuration available there is much more intuitive (you can also import Eclipse project). However, debugging on their isn't quite as friendly as it is on Eclipse, hence why I still use Eclipse. In addition the "project scanning" feature of Netbeans is still a work in progress.
1

No need to close Eclipse. Open .project file using Notepad++, find link to the existing source/folder and delete it. Save the file. Refresh the project in Eclipse. Now you should be able to link it again.

Comments

0

I had a problem where I had created a /src directory in my working directory and then wanted to link another directory with additional files to import. The "existing directory" turned out to be because the directory I was trying to link was also called "/src", even though the path was different. I guess Eclipse can't have two /src directories in the same project, similar to trying to mount two file systems at the same node. I rearranged the directories so there was only one /src, and all was well.

Comments

0

There were conflicts when I tried to update my project which resulted in creation of multiple .classpath files.. SO removing the copies and reverting the latest .classpath file and then refreshing/rebuilding project ,solved the issue for me.

Hope it helps!

Comments

-1

Sometimes the simple refresh (Greg Adamski's answer) does not work, e.g. because the source folder is not in the src-directory (in my case, I had to reference Swagger auto-generated code which was located deep in the target/.... directory after a Maven Build).

In this case, right click the project, open the 'Build Path' -->'Configure Build Path' dialogue, select the 'Source' tab and select your additional source folder via the 'Add Folder' button.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.