I have an Eclipse project with the following directory structure:
MyProj >> src/main/java >> src/main/config >> src/test/java >> src/test/config
Inside src/test/config I have a properties file called app.properties , full of properties that are used by both classes in src/main/java and src/test/java .
All the code that I use to search for the properties file looks like this:
try { Properties props = new Properties(); props.load(new FileInputStream("app.properties")); someString = props.getProperty("app.title.color"); // etc. } catch(Exception exc) { // Handle exception... }
However, when I run this, I get the following error (handled inside the catch clause above):
java.io.FileNotFoundException: app.properties (the system cannot find the specified file)
But when I move the app.properties file to my project root (at the same level as, say, src/main/java ) and re-run the code, it works fine.
Obviously, this is a class problem. If I go to Build Path >> Configure Build Path >> Source , I see that src/test/config is actually the source folder in the build path. This may not mean it is also on the way to class !!!
How to configure Eclipse to search for src/test/config in the class path so that I can place my properties file there, but still have it available at runtime (when doing unit tests)?
Thanks in advance!
source share