views:

146

answers:

1

I have an application that uses a properties file that was added by hand at the /project/bin folder (Eclipse project). The application locates the file using:

this.getClass().getClassLoader().getResourceAsStream("filename.properties")

Now I want to add this file in Eclipse, so it's actually part of the project. In which directory should I create the file and how can I make sure the application will find it?

Thanks.

+3  A: 

You can put the .properties file anywhere under a project source directory (src by default) to make it wind up in the build directory (bin by default) as a "resource", when the project is built. Since the bin directory is generated, you can't modify its contents by hand, in the way you describe.

There's no need to call getClassLoader(); just getClass().getResourceAsStream("foo") is fine.

Jonathan Feinberg