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.
You can put the .properties file anywhere under a project source directory (
srcby default) to make it wind up in the build directory (binby default) as a “resource”, when the project is built. Since thebindirectory is generated, you can’t modify its contents by hand, in the way you describe.There’s no need to call
getClassLoader(); justgetClass().getResourceAsStream("foo")is fine.