The Answer to Life, the Universe, and Everything

Showing posts with label config. Show all posts
Showing posts with label config. Show all posts

Friday, November 23, 2007

Java:Loading the file

The dev environment and the actual service server are different and often face the problem of path to the config file with FileNotFound Exception or so. Here is a solution.

URL propXML = this.getClass().getResource(RESFILE);
Configuration config = new XMLConfiguration(propXML);


or

ClassLoader loader = Thread.currentThread().getContextClassLoader();
DOMConfigurator.configure(loader.getResource("log4j.xml"));