• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Jars inside one jar?

 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
I know that this can be done.
I want the user to set the classpath to the enclosing jar file.
The other jar files s'd be automatically be available.
What s'd i specify in the manifest file?
Encloser.jar
-- a.jar (specifies the main in it's manifest)
-- b.jar
Now i want the user to set the classpath to Encloser.jar and say
java -jar Encloser.jar
==> This s'd result int he main class inside a.jar to execute.
How can this be done. Can someone supply me the manifest of Encloser.jar
thanks in advance,
karthik.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A jar file is just a zipped file that maintains the subdirectory structure.
Inside Encloser.jar you have a set of subdirectories. Some of them contain other jar files that are just a futher breakdown of subdirectories. In the end the Encloser.jar has to have a manifest file that names the .class file in a.jar to kick off, with the complete subdirectory location spelled out - starting from the location that Encloser.jar is in.
And get rid of the Manifest in a.jar. You will confuse the rest of us.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You know, now that I think about it, I have never really SEEN a jar file inside another jar file - and I have surely never tested to see if it works.
Tell us how it works out.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i c'dnt get that to work :-(.
So i have a final.jar which in turn has some jars inside it + directory structures / files etc.
So i had to ask the client to extract the enclosing jar file.
One more thing i found out while working with executable jar files :
I posted it in the ranch but no one has has confirmed it as yet in the forum.
the class-path setting is immaterial when using executable jar files. IF the executable jar refers to other jars, then we normally have a
Class-Path attribute in the manifest.
So depending upon this attribute setting the other jars are searched.
Class-Path: another1.jar another2.jar
another1.jar and another2.jar will be searched only in the same directory as the executable jar file. Explicit classpath settign does'nt help.
if we say
(in manifest),
Class-Path: .\folder\another1.jar .\folder\another2.jar
then it w'd search in folder named "folder" relative to the location of the executable jar file.
I c'd'nt digest it early on that i c'd ship an application that did'nt need a classpath setting!
Just make sure that the dependent jar files are in the same folder as executable jar file or in a specific subfolder relative to the executable jar.
Am still waiting for responses though. My application works just fine.
karthik.

Originally posted by Cindy Glass:
You know, now that I think about it, I have never really SEEN a jar file inside another jar file - and I have surely never tested to see if it works.
Tell us how it works out.


 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Cindy Glass:
You know, now that I think about it, I have never really SEEN a jar file inside another jar file

Any application server that will run war files without unpacking them (which ones do anyway?) runs jars within jars.
- Peter
 
I love a good mentalist. And so does this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic