How to retrieve .properties?

Posted by user1014523 on Stack Overflow See other posts from Stack Overflow or by user1014523
Published on 2011-11-13T17:39:31Z Indexed on 2011/11/13 17:50 UTC
Read the original article Hit count: 455

Filed under:
|
|
|

Im developing desktop java application using maven. I got a *.properties file that I need to retrive during execution (src/resources/application.properties). The only thing comes to my mind is to use:

private Properties applicationProperties;
applicationProperties.load(new BufferedInputStream(new FileInputStream("src/resources/application.properties")));

This would work if I run my application directly from IDE. I want to to keep outpout hierarchy clear, so I set maven to copy resources folder dircetly to target folder (which is a basedir for the output application). This way application.properties file won't load (since I have target/resources/application.properties but not target/src/resources/application.properties).

What is the best way to manage resources so they work both when I debug from IDE and run builded jar file directly?

© Stack Overflow or respective owner

Related posts about java

Related posts about maven