Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Loading from classpath dont work



Back to:
www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html
.

ClassLoader loader = ClassLoader.getSystemClassLoader();

System.out.println(loader.getClass().getName());

InputStream in = null;
if (loader != null) {
URL url = ClassLoader.getSystemResource("com/comp/resource/workflow.properties");

String path = System.getProperty("catalina.home") + File.separator+ "workflow.properties";
System.out.println("Path"+path);
if (url == null) {
in = loader.getResourceAsStream("com/comp/resource/workflow.properties");

if (in != null) {
props = new Properties();
props.load(in);
System.out.println("property val :" + props.getProperty("PushAppImpl"));
}

}
if (url != null) {

in = url.openStream();
System.out.println("property val :" + props.getProperty("PushAppImpl"));
} else {
System.out.println("STILL NULL");
}

NO matter what it gives Back Null
the jat filwe is in the LIB directory why is it not able to locate the propertiers file?

Your rating: None Average: 2.8 (4 votes)