0

I've found a bunch of Stack Overflow Questions and Answers, but so far I haven't found any that work for me. I am trying to make an executable jar in Eclipse from a program which requires an extra jar and a dll. The way I got this to work properly in Eclipse is by configuring the Build Path as shown in this image. The hierarchy of the project is this. I've tried messing with the Manifest file a bit, but I haven't made any progress with that.

I've been running the jar by using java -jar /path/to/jar and I keep getting an error saying Exception in thread "main" java.lang.NoClassDefFoundError: com/jacob/activeX/ActiveXComponent .... I've tried defining a path to the jar using -Djava.library.path=/path/to/jar and I get an error saying Error: Could not find or loaded main class outlook_dl_2.jar.

Is there any way to solve this without using a third-party application like One JAR? That's the only thing I can find that I haven't tried and I'm trying to avoid it if possible, since I feel like it really shouldn't be necessary. I'll use it as a worst-case scenario, but I would like to get this working without it.

Anyone know what I'm doing wrong here?

Community
  • 1
  • 1
  • One big JAR instead of a JAR plus all required JARs is often called [_fat JAR_](https://stackoverflow.com/q/19150811/6505250). As far as I know, a DLL can't be in a JAR. But you can extract the DLL into a temp directory and load it at runtime (instead of using `-Djava.library.path=...`): – howlger Nov 08 '17 at 14:28
  • Are u sure the path `/path/to/jar` includes the `main` method? – Sal-laS Nov 08 '17 at 14:34
  • @howlger How would I go about that? I want to be able to deploy this to other people and I'm trying to have the least overhead for non-technologically savvy people as possible... – Jason Blocklove Nov 08 '17 at 15:15
  • @Salman I would guess that it doesn't. How would I include both the path to the library and the path to the main method? – Jason Blocklove Nov 08 '17 at 15:16
  • @JasonBlocklove For the fat JAR and to specify the main class I would use an Ant script (see [_Merging archives_ example here](https://ant.apache.org/manual/Tasks/jar.html)). For the DLL I would extract it from the JAR into a temp folder and then use [`Runtime.getRuntime().load(...)`](https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#load-java.lang.String-) (that's how I've seen it elsewhere). – howlger Nov 08 '17 at 16:30
  • @JasonBlocklove I recommend, first build a fat JAR and the DLL as an extra file. To include the DLL in the JAR, extract it and load it, is independently of the fat JAR and you can do that when the fat JAR + separate DLL works. – howlger Nov 08 '17 at 16:41

0 Answers0