| [news.eclipse.newcomer] Re: Help with jar export and external library |
Eric Rizzo wrote:B) Provide a mechanism by which the user can configure your app start-up to tell it where to find the libraries it needs.
Option A is generally preferred, because it reduces any headaches like you are experiencing. Option B relies on the user not only having the libraries but also being able to configure your app to point it in the right place. When going the option B route, you will almost certainly have to provide one or more script files (shell or batch) that can be tweaked to set the -classpath and -Djava.library.path appropriately. It is more work for the user and the developer, which is why I always choose option A whenever possible.
Therein lies the rub. I did a bit more research and discovered something I should have known in the first place: <argh>Java ignores the classpath when you're running a jar</argh>. I thought I could deploy with a batch file that would invoke my jar file using the -cp option, and the user would edit the batch file once to put in the correct path to the third-party jar. No joy. Unless I'm missing something, either I provide a batch file that gets the path to the library jar from the user, rewrites the manifest file to include that classpath, and repackages the jar to include the new manifest, or else I bail on the jar entirely and just send the user the class files (which is looking better and better).
I don't suppose anybody has found a better way to get around Java ignoring -cp when running a jar?
Hope this helps, Eric