I cannot figure out how to implement this on my application.
I want to have an xml (or some file) where the person in charge of the administration of the app chooses where the Root_Dir is.
Right now it is hard-coded something like C:\MyAppRootDir but I want that this path could be modified whenever the admin wants.
Any ideas?
Cheers
There are several ways to provide external configuration to a webapp.
Create a properties file and put it in one of the paths covered by webapp’s runtime classpath, or add its path to the webapp’s runtime classpath.
E.g.
/path/to/config.propertieswith this contentYou’ll be able to grab it by the classloader.
Based on your question history, you’re using/targeting Tomcat. The admin could edit the
shared.loaderentry of its/conf/catalina.propertiesto point to the folder where this properties file is located.Add a VM argument to Tomcat startup script.
It’s available as follows:
Set an environment variable.
It’s available as follows: