Luther
Luther

Reputation: 1848

Getting eclipse to recognise new source folders

Apologies if this has been asked before - if it has, I'm obviously searching for the wrong thing. It's not the first time I've been stumped by java, eclipse and how they find source files.

I have a folder of java sources and I wish to copy them in to the 'src/com' folder and have this 'just work'. If I copy the files directly, eclipse and java fail to recognise them so I assume that somewhere there's a file that tells the IDE that there's a folder of files in there that's included in the project. I'd like to know how to do this via config files and via the IDE UI.

Unfortunately, the two obvious files (.project and .classpath) don't seem to reference the existing directories at all (.classpath contains a line

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

that I'd assume would auto-scan that directory for files but it doesn't appear to)

Finally, are .classpath and .project java concepts or eclipse concepts?

Thank you for your time.

Upvotes: 2

Views: 2755

Answers (2)

Andrei Tomashpolskiy
Andrei Tomashpolskiy

Reputation: 170

If I copy the files directly, eclipse and java fail to recognise them

Eclipse does not watch the file system, so if you make any changes to project files outside the IDE, you should refresh the project. Same story with tools that execute as external processes, e.g. ant builds.

so I assume that somewhere there's a file that tells the IDE that there's a folder of files in there that's included in the project

You may configure sources, output directories and dependencies in "Build path" section of project config. Or RMB on project and select "Configure build path".

Finally, are .classpath and .project java concepts or eclipse concepts?

Yes, but they are also recognized in other IDEs, for instance IDEA Intellij. See What's in an Eclipse .classpath/.project file?

Upvotes: 1

greg-449
greg-449

Reputation: 111217

Eclipse has its own list of files in the folders stored in the .metadata, you have to use File > Refresh to tell it to refresh that list.

You can also tell it to do the refresh automatically in Preferences > General > Workspace Refresh using native hooks or polling check box.

You can also do this programatically using the refreshLocal method of IResource (so also in IProject, IFolder and IFile).

Upvotes: 5

Related Questions