| [news.eclipse.newcomer] Re: Help with jar export and external library |
Hi all,
I have a Java project that requires third-party software supplied as a jar file (installed at location /A/their.jar on my box) and a native library (DLLs at location /B/ on my box). I put the jar file at A on the build path as an external jar (location B is on my system command path) and the project compiles and runs fine from inside Eclipse. The problem comes when I export a jar file and try to run it outside Eclipse.
Running the jar generated from this set up causes NoClassDefFound errors as soon as it needs something from the external library, even though /A/their.jar is on my system classpath, and regardless of whether I specify it via -classpath (or -cp) in the invocation. Note that if I unpack the jar archive and run the main class file directly, it runs fine.
After assorted failed efforts (and considerable swearing) I changed my build path to show /A/their.jar as part of a user library, rather than just an external jar. When I export my app as a jar and run it, using the -Xbootclasspath/a: option to add /A/their.jar to the boot path, it finds the bleeping classes -- but I get an error message because it can't find the native libraries in /B (again, regardless of whether I specify it through -Djava.library.path, put it on my system command path, fire flares from it's home directory, ...).
So what's the secret handshake? The user will have /A/their.jar and some version of /B (which is platform dependent) installed, but not at /A and /B respectively, so I need a way for the user to specify those paths and get the bleeping jar file to run. Having the user unpack the jar and run the main .class file is an option, but not an attractive one.
Hope this helps, Eric