Q:

getResourceAsStream while running .jar

I have the following package structure in Eclipse:
MyProject
|___ src
    |___ package1
    |___ file.properties

I read the file.properties in 2 different ways:
prop.load(getClass().getResourceAsStream("file.properties"));

and
BufferedReader br = new BufferedReader(new FileReader("src/file.properties"))

The file.properties can be modified at runtine, so when I provide the jar file, I suggest user to create a src folder at the same level of the jar file and put the file inside it.
However, before I create the jar, I need to specificy the src folder in the file path:
prop.load(getClass().getResourceAsStream("src/file.properties"));

while the FileReader call still works.
How can I set a common filepath, able to work in both cases (eclipse/development environmente and jar/production environment)?
Thank you

A:

You can add external src directory to the Class-Path entry in JAR's manifest. That will make the src directory accessible for getResource().
I don't know however, how it will behave on changing content of that directory on runtime - never tried.
FYI:
Reading file in Eclipse "works" little bit by accident. If you run your application , Eclipse is not building whole JAR and using it. It only compiles java files to .class files and uses them. Whole application is still on the filesystem as plain directories and files insteed of in JAR file, and that is why reading from file works. 
It wont work in case of JAR files (and resources inside) because you cannot read files directly from the JAR(zip) archive. If you would deliver your application in exploded form, it would work for client as well as it works for you in Eclipse (and without additional directories). 

