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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -