commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rashid Jilani" <jil...@lifebiosystems.com>
Subject RE: [component]commons.configuration.PropertiesConfiguration - load properties from classpath
Date Fri, 09 Jul 2010 20:14:09 GMT
It depends in which context you need to load resource, web or desktop
application.

In desktop application let's say you have the root application in the folder
Foo and there is a folder config under folder Foo where you have your
configuration file name config.xml, you can use something like this

String nativeFileSeperator = System.getProperty("file.separator");
        String currentDirectory = System.getProperty("user.dir");
        String configurationFile = currentDirectory + nativeFileSeperator +
config +  nativeFileSeperator + 'config.xml';

In case of web application you can use the servletcontext. getContextPath()
which will return the application path of the current context, then you can
load the resources in the relative folders under the current context path.

 

-----Original Message-----
From: apreg [mailto:apreg@mailbox.hu] 
Sent: Friday, July 09, 2010 2:51 PM
To: user@commons.apache.org
Subject: Re: [component]commons.configuration.PropertiesConfiguration - load
properties from classpath


Yeah, you have right. I works, but what if I'd like to put my .properties
files elsewhere not in the root of my source folder. What should I write in
the vm arguments to accomplish this and how should  I reference to the
specified .properties file from code? Sorry if I am on the wrong way.
-- 
View this message in context:
http://apache-commons.680414.n4.nabble.com/component-commons-configuration-P
ropertiesConfiguration-load-properties-from-classpath-tp2283842p2284016.html
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message