wood burning stoves 2.0*
The moose likes Java in General and the fly likes How to read .properties files on classpath in a web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to read .properties files on classpath in a web application" Watch "How to read .properties files on classpath in a web application" New topic
Author

How to read .properties files on classpath in a web application

Ajay Kamble
Ranch Hand

Joined: Jan 23, 2009
Posts: 51
Hello All,

I am using below code to read the properties files that are on the classpath,

ClassLoader.getSystemResources("my-config-file.properties");

What I want is that at runtime I may have various jars attached and each jar might have this property file. So with above code I want to read all properties files available and make a combined configuration.

Now this code was working well for the simple java project. But it does not work for a web application (deployed on WebSphere). I guess the reason is that in the case of web applications multiple class loaders might be involved.

What do I do so that my code will read all properties files. Is there any project that is already doing this, for example Commons Configuration?

-Regards
Ajay
 
jQuery in Action, 2nd edition
 
subject: How to read .properties files on classpath in a web application
 
Similar Threads
Putting un-jarred config files on the manifest classpath
Jar files and manifest classpath
Eclipse: What, exactly, does the "Add External Class Folder" button really do?
Properties questions
How to set external config directory on classpath ?