• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refering a jar file from another jar

 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have one jar file that needs to refer some of the files from xerces.jar.
I know that we cannot include a jar within a jar.
The other way is to have a manifest file. But the problem I am facing while using the manifest file is when I place both the jar in same folders than everything works but if i put them in different folders or drives (D:some.jar and c:xerces.jar) than I get classnotfound exception.
Can someone please tell me how should I refer a jar from another jar.

Manifest.mf file contents.

Manifest-Version: 1.0
Class-Path: xercesImpl.jar

Thanks
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Class-Path entry in the manifest should contain the path of the referred-to jar file relative to the jar file that contains the manifest.

So, if you go to the command line and change your current directory to the directory where your executable jar file is, then typing "dir" followed by whatever is in the Class-Path entry should show you that referred-to jar.

However my preference would be to put the referred-to jars in the same directory as the executable jar. Makes things much simpler. If you were planning to keep things like Xerces in a standard directory and have all your executable jars refer to that, I think that's false economy. Besides which it isn't a practical strategy if you're going to distribute the executable jar along with all its dependencies.
[ March 05, 2008: Message edited by: Paul Clapham ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic