views:

218

answers:

1

I had a little quicky project in mind, I created a normal Java Project in Eclipse, placed a XML file quick'n'dirty in the src folder and I was baffled when Eclipse can't seem to locate the XML file in the classpath. After a little test it turns out that files with other extensions are perfectly located.

Here's a screen which says it all:

alt text

It prints null for the /test.xml resource. The Class#getResourceAsStream() obviously doesn't make any difference.

I checked the project's /bin folder and the XML file is indeed not there. I've checked all settings to see if there isn't some filter to exclude certain files from taking in the /bin folder, but all in vain. The only way to get it to locate the XML file is to externalize the file outside the project on the local disk file system and adding its path as "External Class Folder" in the project's build path.

I've never seen this before, but I can also not remember that I ever used this way to locate the XML files, they're normally already in an "External Class Folder".

Any suggestions? I'm using Eclipse Galileo with build id 20090920-1017. By the way, I don't need to get it fixed as-is, externalizing it is also OK, but I'd like to know how and why this would happen :)

+4  A: 

This sounds vaguely familiar. Go to Prefs -> Java -> Building -> Compiler -> Output Folder, and make sure the "filtered resources" field doesn't include XML files. Also check the project-specific preferences.

I seem to recall that older versions of Eclipse had this in by default, but I'm not sure why it'd happen with a newer version.

skaffman
Thanks, that was it! As to the version, I guess that it must be caused because I always exported/imported the preferences in flavor of `epf` file when upgrading Eclipse.
BalusC