commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: [component]commons.configuration.PropertiesConfiguration - load properties from classpath
Date Sun, 11 Jul 2010 05:34:00 GMT
In our environment we want the configuration files to reside outside the application. In JBoss,
we place the files in default/server/configs. In our startup script we add that directory
to the -cp. We use this for commons configuration's files but also for several other things
that looke for their files in the classpath.

Ralph

On Jul 9, 2010, at 1:14 PM, Rashid Jilani wrote:

> 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
> 


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


Mime
View raw message