• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jars inside jar ? can it work ?

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • 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?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic