Click to See Complete Forum and Search --> : Picking up properties using ClassLoader.getSystemResource


james_
12-17-2007, 10:28 AM
I have some code from a jar file that uses ClassLoader.getSystemResource("File.properties"). How can I set this system variable in a 'good' way? Or, to phrase it a little differently, does anyone know how to do this without editing my classpath and having an absolute reference to the file? This is a pretty big project with many people working on it, so it's not very practical to have everyone working with separate configuration instances.

I did find this link, but couldn't quite figure out how to use it correctly (http://eclim.sourceforge.net/vim/java/classpath.html). It's not very helpful when there's obvious typos in the example!

Thanks for any help!

Khalid Ali
12-18-2007, 02:56 PM
for this to be used correctly you will need to put the resources in the root folder where the class file is at. for example project directory is
dev/classes
dev/src
dev/properties/File.properties

once you compile your compiled code will be in classes folder and when you run that class, it will look for File.properties in the classes folder.
Hence you will need to put the file in the root folder where class files are and that will make you independent of any dev environment as long as they have the file in the root directory

itsmeranu
09-29-2008, 08:01 AM
Thanks! i put my properties files in /bin folder of my project
It works :)