dcsimg
How do I package a log4j.properties file in a jar file I am distributing?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   dave_cleary
Posted On:   Monday, January 8, 2007 10:40 AM

I'm trying to package a home-brewed java application into a jar to send to a customer. I have a zip file with my main jar (which includes various /resources) and a couple of other jars (log4j, etc). The app works great on my machine, with everything in one directory, but I'm trying to put things into a reasonable directory structure, so I've moved the log4j.properites file into ..config. I built (my first) Manifest.MF file for the jar, which contains: Main-class: my.Tool Class-Path: ../lib/dom4j.jar ../lib/log4j-1.2.8.jar ../config I've tried a dozen different ways to get log4j to find the .properites file, including a wrapper batch file that specifies -cp and specifying the directory in the Manifest's classpath.    More>>

I'm trying to package a home-brewed java application into a jar to send to a customer. I have a zip file with my main jar (which includes various /resources) and a couple of other jars (log4j, etc). The app works great on my machine, with everything in one directory, but I'm trying to put things into a reasonable directory structure, so I've moved the log4j.properites file into ..config. I built (my first) Manifest.MF file for the jar, which contains:

			
Main-class: my.Tool
Class-Path: ../lib/dom4j.jar ../lib/log4j-1.2.8.jar ../config


I've tried a dozen different ways to get log4j to find the .properites file, including a wrapper batch file that specifies -cp and specifying the directory in the Manifest's classpath. I'd really prefer to put the log4j file IN the jar file, since the customer will not be editing the file.


NOTE: This application cannot assume anything about the customer's CLASSPATH environment variable, so I can't just 'put the file in the classpath'.

   <<Less

Re: How do I package a log4j.properties file in a jar file I am distributing?

Posted By:   Christopher_Koenigsberg  
Posted On:   Friday, January 12, 2007 05:49 PM

try with the log4j.properties file in the root directory of the jar file, since that root directory should be automatically on the CLASSPATH if you're executing from the jar?

Re: How do I package a log4j.properties file in a jar file I am distributing?

Posted By:   dave_cleary  
Posted On:   Monday, January 8, 2007 02:21 PM

Not an answer, but an update. I spent an hour tweaking the classpath entries in my wrapper batch file and in the manifest file, with no luck. I went back to my original batch file, and eventually realized that when my batch file invokes my jar using

java -classpath ... my.class

Then log4j worked, but when I used

java -classpath ... -jar my.jar

with the proper manifest, then everything else in my program worked, except log4j. Why should that matter? It seems that when I use the -jar method, log4j just fails, regardless of where I actually put the log4j.properties.
I suppose at this point I should mention that I'm running java version 1.4.2_08 and log4j-1.2.8.
About | Sitemap | Contact