java - Resources and config loading in maven project -
i'm using maven desktop applycation. read maven standart directory layout , have project structure now:
app |-- pom.xml `-- src |-- main |-- java | `-- java classes |-- resources | `-- images | `-- app images `--config `--config.xml
i want find way load resources , config files. read articles , topics , found (simplified example code):
//class loading config public class preferences { public preferences() { inputstream image = preferences.class.getresourceasstream("images/image.png"); inputstream config = preferences.class.getresourceasstream("config.xml"); } }
but image , config variables contains null. trying different variants of loading (from root folder, this.getclass() instead of preferences.class, , others), have null. don't understand resource loading system , didn't find documentation it. nice, if gives explanation mechanism (or give link on docs). so, main question is: how can load resources , config files?
public preferences() { inputstream image = this.getclass().getclassloader().getresourceasstream("image.png"); inputstream config = this.getclass().getclassloader().getresourceasstream("config.xml") }
Comments
Post a Comment