File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Class-path in manifest file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Class-path in manifest file" Watch "Class-path in manifest file" New topic

Class-path in manifest file

Matthew Sessoms

Joined: Apr 28, 2011
Posts: 6
Hello all,
I have a jar file that contains (among other things) a 'main' & 'lib' folder. I have the main-class set to main.Start. For the class-path, I want to reference the lib folder that's inside the jar file. I have lib/xx lib/yy lib/zz and so on. However, it's not recognizing the dependencies when I run it. In Eclipse, it runs fine. If I put ../lib/xx, the jar file references the lib folder that's *outside* the jar file (i.e., aa/dist/jar.jar, it references aa/lib). I want to be able to set the class-path to reference items *inside* it's own jar file. Is there a way to get around this? I've tried a simple jarring of all the jar files for outside the main jar file, but I can't get it working.

John Jai

Joined: May 31, 2011
Posts: 1776
Entries in a manifest files' classpath is relative to the jar file's location. It don't search inside for a folder named lib but relative to the location where jar is placed.

So better create a lib folder alongside the jar file, place all the necessary jars in it and modify the manifest file accordingly.
I agree. Here's the link:
subject: Class-path in manifest file
It's not a secret anymore!