• 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

jars inside jar ? can it work ?

 
Ranch Hand
Posts: 620
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello
i have jar that contains jars (this is used to be web application that contains the jars in the WEB-INF/lib dir , but now i need to export this
application as stand alone jar im export the application as jar file that contain the jars inside the jar when i run one of the application method
from out side class it dont find the jars even if its inside the jar
only when i put them in the classpath the method invoke like it should .
so to be sure jars cant be inside main application jar?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java doesn't support JARs inside JARs by itself.

You can have JAR files inside a WAR (in the WEB-INF/lib directory). The web container has a special classloader that will look for the JARs in the WEB-INF/lib directory inside a WAR.

But the normal Java launcher (used to run stand-alone Java apps) does not have any mechanism to look for classes in a JAR inside another JAR.

If you really want this you can write your own ClassLoader that supports this, but that's not so easy to do.
[ March 06, 2007: Message edited by: Jesper Young ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jesper Young:

If you really want this you can write your own ClassLoader that supports this, but that's not so easy to do.



Or simply use http://one-jar.sourceforge.net/
 
reply
    Bookmark Topic Watch Topic
  • New Topic