wood burning stoves 2.0*
The moose likes Java in General and the fly likes Can you jar jar files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can you jar jar files?" Watch "Can you jar jar files?" New topic
Author

Can you jar jar files?

Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
I mean, if you're building a final deployable, double-clickable jar file, and you want to jar up all your own compiled classes, PLUS all the jar libraries you're using in one jar file, can you do that? When I jar all my classes and jars, I can verifiy in WinZip that they have in fact all been added. And I've added a Manifest so I can double-click the jar file and it launches and starts my Java app.
BUT, the problem is, that my classes don't see *any* of the imbeded jar files. So I don't know #1, if you can jar jar files, or #2, if you can, what you have to do to get your classes to see them...how do you specify a classpath to include jars already inside the main jar file??


Rob
SCJP 1.4
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
Originally posted by Rob Ross:
I mean, if you're building a final deployable, double-clickable jar file, and you want to jar up all your own compiled classes, PLUS all the jar libraries you're using in one jar file, can you do that? When I jar all my classes and jars, I can verifiy in WinZip that they have in fact all been added. And I've added a Manifest so I can double-click the jar file and it launches and starts my Java app.
BUT, the problem is, that my classes don't see *any* of the imbeded jar files. So I don't know #1, if you can jar jar files, or #2, if you can, what you have to do to get your classes to see them...how do you specify a classpath to include jars already inside the main jar file??

i think "Class-Path" attribute in the manifest.mf is for u. and if i am not wrong u had already wrote Main-Class attribute their for executing that jar by double clicking on that.
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Yea, I tried adding all the inner-jars on the Manifest's classpath, but they're still not visible.
They're only visible when the inner-jars are *external* to the executable jar file, and I have them listed in the executable jar's Manifest file.
It seems that nesting jars just isn't something that works.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
You have to unjar the outer jar before you can execute the inner jar.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
I don't know if it can be done neatly with java configuration options, but you can always count on the trusty URLClassLoader.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Rob Ross:
Yea, I tried adding all the inner-jars on the Manifest's classpath, but they're still not visible.

How did you specify this? Did you try the jar-protocol in the url? It's pure speculation of mine, but perhaps something like "jar://myjar.jar/..." would work?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can you jar jar files?