A general approach is to use paths relative to the system property. This allows you to specify the root folder in a specific OS format ( C:\... or /opt/ ) and attach the relative part later.
Please note that Java can handle relative Windows and Unix paths, so new File( "C:\\app", "conf/log4j.xml" ) will try to open C:\app\conf\log4j.xml .
In your case, you can use this code:
File confFolder = new File( System.getProperty( "confDir" ) ); File log4j = new File( confFolder, "log4j.xml" );
Another option is to replace the variable names in the configuration files. So you can have
<logConfDir>${appRoot}/conf</logConfDir> <log4j>${logConfDir}/log4j.xml</log4j>
If there is a System logConfDir property, it should overwrite the configuration parameter. This will allow customers to do whatever they think is necessary.
source share