Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse doesn't put XML files in project's own buildpath

I created a standard Java Project in Eclipse, placed a XML file in the src folder with the intent to grab it by Class#getResourceAsStream(), 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:

enter image description here

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 ending up in the /bin folder during the build, but all in vain.

How is this caused and how can I solve it? I'm using Eclipse Galileo with build id 20090920-1017.

like image 992
BalusC Avatar asked Feb 20 '10 20:02

BalusC


People also ask

Where do I put XML files in Eclipse?

Clicking on the File menu and selecting New → XML File or.

Why XML file is not opening in eclipse?

To open XML files in the default editor: In the DITA CMS Eclipse Client, click Window > Preferences. In the left pane, click DITA CMS > General Behavior. Clear the Open unlocked document in Read-only Editor checkbox.

How do I save an XML file in eclipse?

Invoke New XML File wizard using workbench menu File>New>Other>XML>XML. On the XML File Name page select a project or folder to contain the XML file and type a name for it. Next, select the option to Create XML file from an XML template.


1 Answers

This sounds vaguely familiar. Go to Prefs -> Java -> Compiler -> Building -> 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.

like image 56
skaffman Avatar answered Sep 22 '22 12:09

skaffman