The ideal way to populate a java.util.Properties object seems to be by using some variation on
properties.load(ClassLoader.getSystemClassLoader().getResourcesAsStream(String className));
The big idea being to point Properties.load at a InputStream of a class, rather than at a path.
How can this be done using org.apache.commons.configuration.Configuration?
The constructors of the different containers (e.g.
org.apache.commons.configuration.PropertiesConfigurationandorg.apache.commons.configuration.XMLPropertiesConfiguration) internally take care of this if you pass them aString. They internally use the API inorg.apache.commons.configuration.ConfigurationUtilsto try and find the resource in the user home directory, the current classpath and the system classpath.Incidentally, you might find this article useful when trying to figure out the “correct” class loader to use when loading properties files from the classpath.