Probably it is discussed somewhere but I failed to find it.
I need to load class properties (java.util.Properties) inside class static initialization block. This is to make possible to access some class general options even without its objects creation. To do so I need appropriate Class object. But of course access to such Class object fails on null object. Something like this.
Class Name {
private static Properties properties;
static {
Name.properties = new Properties();
Name.properties.load(Name.class.getResourceAsStream("Name.properties"));
}
}
Any idea how to handle this situation?
UPDATE:
It was resource name (should be "/Name.properties" for my case). Everything else was OK.
+1 for all meaningful answers from me and ... don't forget to check operations one by one :-).
propertiesstatic too.getResourceAsStream. Make sure Name.properties is in the same directory as Name.class in your .jar file.