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

Jar within Jar?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK I've read https://coderanch.com/t/391746/java/java/Game-Tutorials-Creating-Executable-JAR
but I still don't seem to be able to access a jar within a jar.
Maybe what I'm trying to do is impossible and I misunderstood the above. Reading the section of that thread beginning 'The use of a JAR file within a JAR file is the winner.' it suggests to me that FooJar.jar is entirely self-contained. In other words I want to be able to run FooJar.jar straight off a floppy disk with no separate copy of FooFrameJar.jar .
It appears that the 'Class-Path: FooFrameJar.jar' line in the manifest just tells the JVM to look in the directory from which FooJar.jar was invoked for FooFrameJar.jar, and, indeed, if it is present in the directory is executes correctly.
BUT...if the FooFrameJar.jar must be present in this directory then why on earth have we bothered to include it within FooJar.jar in the first place???
Please help me get rid of my infernal:
Exception in thread "main" java.lang.NoClassDefFoundError: foobar/FooFrame
at Foo.main(Foo.java:7)
TIA,
Tom
[ January 12, 2004: Message edited by: Thomas Hood ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BUT...if the FooFrameJar.jar must be present in this directory then why on earth have we bothered to include it within FooJar.jar in the first place???
Right. That was the purpose of the example - to demonstrate using a JAR that is contained within a JAR. You don't need FooFrameJar.jar to exist outside of FooJar.jar.
It should work.
[ January 13, 2004: Message edited by: Dirk Schreckmann ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just tried to run the demonstration JAR and I got the exact same error that you get with Java 1.4.2_03.
I then tried to run it with Java 1.5-beta and it worked fine.
I then tried it with Java 1.4.2_02 and it worked fine.
I now I try again with Java 1.4.2_03 and it works fine.
Perhaps there's something wrong with our installations of Java, or perhaps there's a bug in the JRE.
It must be too late at night to be fiddling with this stuff...
[ January 13, 2004: Message edited by: Dirk Schreckmann ]
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello !

I have the same problem. After posting a question in this forum and trying Dirks example to solve the problem I have concluded that this is not possible, not in the way Dirk suggests anyway.
BTW, Have you tried your example on another computer Dirk? Where the included jar is not present? I think you will find that it will not execute. But I hope that I am wrong,
Since the feature of including jar files (probably third party APIs packaged as jar files) inside other jar files seems to be a popular subject. Maybe someone with the knowledge and time could clarify how to destitute Java applications that is dependent on third party APIs in an easy and maintainable manner. Is the solution to package the application, and required Jars in a jar file that the end user have to unpack? Or is it better to write a new class loader, Or to use Web-start ???
Any comments appreciated!!!
/Ztopher
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same problem. After posting a question in this forum and trying Dirks example to solve the problem I have concluded that this is not possible, not in the way Dirk suggests anyway.
BTW, Have you tried your example on another computer Dirk? Where the included jar is not present? I think you will find that it will not execute. But I hope that I am wrong,

You are wrong. The example is correct. The problem I had involved an improperly configured JRE installation.
 
Thomas Hood
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you fix your JRE then? What was the problem?
Thanks,
Tom
 
Martin Swift
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That sounds great :-)
Can you please give some information on how you solved this problem.
Cheers
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have been trying to put a jar in side another jar for a little while. It is the requirment that the jar files runs on at least JRE 1.3.1. To date I have not managed to get it to work.
The only way I have found to get around this problem is to extract the jar you want to place in the main jar to a directory. Then when you build you jar, include the extracted files.It is a longer process but it does work.
Chris.
 
Martin Swift
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've found the same thing, I am sorry to say :-(
 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Same here. In my Ant script, I extract the 3rdpart jar(s) into my target directory then jar up the whole target dir. Not the best solution, but it works.
Brian
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic