Here's the situation: I got 10 projects that need 2 libs to run: Jsoup (A html parser API), and Utils (Framework developed by me).
I want to update that Utils project from time to time, and not have to re-compile 10 projects everytime that happens..
So I started using Ant, and after a great amount of time figured this much out:
Problem is... When I try to run it, I get the following error:
RoboBean is a class inside the referenced package, and when I open the jar, I can see that it's in its right place.
I tried exporting the Runnable Jar with Eclipse specifying "Copy required libraries into a sub-folder next to the generated JAR",
thought it'll build 10 folders for 10 projects, which is not what I'm aiming for here...
After doing it, I compared both MANIFEST.MF's... To my surprise, here's what differs:
This is the one generated by Eclipse
And this is the one generated by my build.xml
I already searched all over JavaRanch and StackOverflow and found nothing that could explain / clarify anything...
If that was the problem, than I'd have no hard time to execute the jar manually via command line, which I do. I think it's something related to the path where the jars are placed, but I still can't make it work
When you ask Eclipse to create an runnable JAR, it places all dependent JARs into a lib folder within the JAR and adds classes to the JAR that implement a classloader so that the embedded JARS can be found and their classes loaded. That is why the one from Eclipse runs correctly.
The JAR built by Ant uses relative paths to access the JARs file on the hard drive - if you are not running the app from the correct location, the relative paths will be wrong. It looks like the paths are relative to your project's base directory, which will be fine as long as the JAR is in that same directory. But it looks like the JAR is placed elsewhere, so you need to either use absolute directories, or change the relative directories, or relocate the files.