• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 27235
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. You know how to make it work, you've said that twice. And that's how it is supposed to work.
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this can be done.
Check out the Fat Jar Eclipse Plugin (FJEP) and One-Jar
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic