aspose file tools*
The moose likes Beginning Java and the fly likes jars inside jar ? can it work ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "jars inside jar ? can it work ?" Watch "jars inside jar ? can it work ?" New topic
Author

jars inside jar ? can it work ?

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
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

Joined: Aug 16, 2005
Posts: 13881
    
  10

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 ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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/


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: jars inside jar ? can it work ?
 
Similar Threads
Eclipse Plug-in and dependencies from other JARs
SQL statements in files in jars - best practice suggestions?
Servlet accessing Session Bean (sic)
import statements saga
JVM: Could not find the main class. Program will exit