I\'m working on making my Java app easy to deploy to other computers and am writing an ant script to do so, that is going fine.
I\'m having trouble loading resources
You can use the log4j.configuration
system property when you startup your application:
java -Dlog4j.configuration=config/log4j.properties MyApp
See http://logging.apache.org/log4j/1.2/manual.html under "Default Initialization Procedure".
Regarding the other configuration files not being picked up, what does your Manifest.mf file looks like? Are you using something like
Class-Path: config/configuration.xml lib/yourLibOne.jar lib/blah.jar
in your Manifest.mf file?
Regarding log4j : If you want it to use a different config file from the default, you can use
org.apache.log4j.PropertyConfigurator.configure(...)
Variants of this static method accept URL, Properties or file name.
There is also
org.apache.log4j.xml.DOMConfigurator
for the XML files.
As far as I know, log4j.xml should be at root of your classpath..
and also, you can read your configuration file with below code script. and config directory should be at your classpath.
this.xml = this.getClass().getResourceAsStream("/config/configuration.xml");
Classpath entries should either be directories or jar files, not individual files. Try changing your classpath to point to the config directory instead of the individual config files.
this.xml = Thread.currentThread().getContextClassLoader()
.getResourceAsStream("config.xml");
Better yet would be to just include your config directory in MyProgram.jar. This would prevent you from needing to add it specifically to the classpath.
this.xml = Thread.currentThread().getContextClassLoader()
.getResourceAsStream("/config/configuration.xml");