0

HI I've found myself referencing a JAR archive I made awhile ago in my code. But the JAR I made has references to the JSoup JAR file, which I just discovered is not automatically added as I had assumed it was (stupid assumption). So after looking around Stack-Overflow it seemed that by simply adding some Class-Path information to a custom Manifest I could solve my problem...But I still get a ClassDef error when I try and reference my JAR from the other project.

Manifest-Version: 1.0
Class-Path: "C:\Users\ethan\Documents\ACTUAL My Documents\Libraries\Java Libraries\jsoup\jsoup-                1.6.3.jar"

SO I'm not sure if I wrote the manifest wrong. (I tried with and without quotes, neither worked). I don't have ANY experience in writing manifests, my knowledge came from this post on stackoverflow

Eclipse: How to build an executable jar with external jar?

from McDowell's post.

I've seen a lot of posts suggest using Maven, or a third party application. But it seems like there should be some simpler way to make this happen in Eclipse without installing anything new (as this often can bring on new headaches).

Community
  • 1
  • 1
Ethan
  • 1,206
  • 3
  • 21
  • 39

1 Answers1

1

The Class-Path in the Manifest is only used when you run an executable jar. It won't be used for jar files used as libraries. You will have to tell your main JAR file about it, too.

Thilo
  • 257,207
  • 101
  • 511
  • 656
  • What do you mean my main JAR file? – Ethan Aug 29 '12 at 04:01
  • Or your Eclipse project classpath, or whatever is using that library jar file. Any dependencies of that library are not automatically picked up from that manifest entry. – Thilo Aug 29 '12 at 04:06
  • oh, well the thing is that works for my purposes. But I would like to be able to distribute this library I've written for others to use. And I don't exactly want to include instructions that they must include Jsoup with it whenever they use it.... – Ethan Aug 29 '12 at 04:10
  • Then repackage all dependencies. Same process as making a runnable jar file. Eclipse can do that. But, I have to ask why: If you distribute a *library* you are distributing to *developers*. They'll know how to include them (you can even bundle them in your zip download, just like every open source project out there does, they have a "lib" folder). If you distribute to end users, make a runnable jar with all dependencies included. – Thilo Aug 29 '12 at 04:24
  • SOrry I've never delved into this sort of thing before. How do I go about repackaging all the dependencies in Eclipse? A professor of mine is thinking of using the library in one of his courses, and it's an intro level course. Also it just seems like more trouble to do...I like to try and make things as simple as possible. =D – Ethan Aug 29 '12 at 04:27
  • Look at the linked question. There is an Export>Jar file dialog. But seriously, if the students can learn how to include one jar file, they can include five. Repackaging might break things, especially if you are not sure what you are doing, and unless you want a nice *runnable* (and clickable) one-file-jar, there is no real benefit. – Thilo Aug 29 '12 at 04:35