This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Jar Files in another jar file (MANIFEST.MF Question) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Jar Files in another jar file (MANIFEST.MF Question)" Watch "Jar Files in another jar file (MANIFEST.MF Question)" New topic
Author

Jar Files in another jar file (MANIFEST.MF Question)

matt eggbeers
Greenhorn

Joined: Mar 11, 2005
Posts: 14
Hey All,
I have a simple soap client written using xfire. It has several jars that it references to other jars. I can run it fine when the directory structure is like this

Directory
|
+- start.bat
|
+- MyJarFile.jar
|
+- lib
|
+- All the referenced jar files

and i use the batch job to add all the jars in /lib to the classpath and it starts great.

My question is, can you add all the third party jars inside the jar file and have tell the manifest file that they are in there? I know you can do it with the jars outside your jar, but what is the syntax of the Class-Path: header in the manifest if the jar is inside the other jar? Well, first off, is this even possible?

THanks,
Matt
matt eggbeers
Greenhorn

Joined: Mar 11, 2005
Posts: 14
Sorry, it looks like my dir structure diagram got messed up while posting.

Anyway, I have a dir, test, and in that dir i have a start.bat file, MyJarFile.jar, and a lib dir. In the lib dir are all the third part jars I am using.

Thanks...
sammaiah kyatham
Ranch Hand

Joined: Aug 03, 2003
Posts: 104
Here is the example, try this.

Add the classpath tag inside Manifest.MF as

Class-Path: ../resources/ cuss.jar cussutil.jar utility.jar dom4j.jar
log4j-1.2.8.jar jflash.jar xerces.jar jacorb.jar commons-lang-2.0.jar
xbean.jar PAWSSchema.jar

Let me know if you still have the problem.

Thanks,
Sam
[ May 01, 2007: Message edited by: sammaiah kyatham ]
matt eggbeers
Greenhorn

Joined: Mar 11, 2005
Posts: 14
First, thanks for the reply. However, I am not sure that you understood my question 100%. The way the you describe, works fine if the lib or resource directory is somewhere OUTSIDE the jar that I am trying to run. What I want to be able to do is package all the needed jars INSIDE one jar file and have the classpath reference the jars inside when trying to execute. I would like to be able to distribute one jar file and one start script and thats it. Is this possible, and if so how?

Thanks,
Matt
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

No. You know how to make it work, you've said that twice. And that's how it is supposed to work.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

You could extract classes from all jar files to the same directory, and add your code to that same directory.
Then you can jar that directory.
Read the licenses of the other jar files carefully. You might not be allowed to de-assemble them, or redistribute their classes in another jar.

Still, I think it's better to leave the jars as they are, and distribute them with your application. That's how it's meant to be done: your code in your jars; libraries that you depend upon in their own jars.

Regards, Jan
[ May 01, 2007: Message edited by: Jan Cumps ]

OCUP UML fundamental and ITIL foundation
youtube channel
Alex Luc
Greenhorn

Joined: Feb 03, 2006
Posts: 13
I think this can be done.
Check out the Fat Jar Eclipse Plugin (FJEP) and One-Jar
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Jar Files in another jar file (MANIFEST.MF Question)
 
Similar Threads
ejb depend on third-party library and Class-Path entry!!!
NoClassDefFoundError running a jar file from the command line
ClassNotFoundException for org.jnp.interfaces.NamingContextFactory
Where to put jar files
Imbedded jar file