Loading a configuration file from the classpath

前端 未结 4 1810
眼角桃花
眼角桃花 2020-12-17 04:43

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

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-17 04:52

    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?

提交回复
热议问题