Referencing a jar inside another jar

Hi All,
If there is a jar "B" inside jar "A", how to include jar "B" in the manifest's classpath of jar "A"??
Regards,
P

let me know if you figure out the answer to this question. I am working on a executible jar and I reference lib/somJar.jar on my manifest file. I thought that it was working because it was loading, but when I tried to move the jexeutible jar it no longer worked. Well I found that it was loading the information from the directory, which was teh same directory that I used to jar the files rather than the actuall jar file.

Similar Messages

  • Referencing Jar inside a Jar

    Hi,
    i have a jar file. the classes inside the jar file refers to classes within another jar file. i packaged the second jar into my jar file but during runtime i get NoClassDefFoundError when i refer to the classes inside the second jar.
    i tried giving the classpath in manifest file but it does not work.
    My question is how to reference a jar which is inside another jar?
    Thanks
    Daniel

    I don't think you can reference classes inside a jar that's itself in a jar.
    However you can definitely reference classes in a (non-nested) separate jar.
    For example A.class in A.jar can reference B.class in B.jar if you put:
    Class-Path B.jar
    in A.jar's manifest file.
    One thing that screwed me up when I first tried this stuff, was that the syntax of Class-Path is not the same as I first expected. If you have more than one path items to put in your class path, you don't separate them with a colon or semicolon, but with spaces.
    good luck
    j

  • Using resources from an external JAR inside a JAR

    Hi,
    I'm trying to package all parts of my application into a JAR file so I can deploy my application using Java Web Start. However, I have an issue.
    I need to use the files from an external JAR, Ice.jar, with my application. Therefore, I included Ice.jar in my build, specifically in the lib/Ice.jar directory.
    This does not seem to be working; my application cannot read the information from the Ice.jar file when I launch my JAR file. It does work in one instance, however:
    I have a directory included in the same directory where my JAR file is. This directory is named lib, and contains Ice.jar. My directory structure is as follows:
    dist
    dist/NVAC.jar //my JAR
    dist/lib/Ice.jar //the external JARMy JAR file, NVAC.jar, will ONLY work if that lib directory is included in its directory. This is NOT what I want to do; I want to include the external JAR inside my JAR file, so a user will only have to download the JAR file. I have included the external JAR inside my JAR as I mentioned previously; at the path myJAR/lib/Ice.jar.
    Therefore, how do I use a resource from an external JAR inside my JAR? Do I have to use ClassLoader? ClassLoader.loadClass() perhaps?
    If I can provide any more information, please let me know.
    Thanks

    Seems to me it isn't practical to want to do things
    that don't work. Especially since you're using
    WebStart and it takes care of dependent jars
    automatically for you if you configure things
    correctly, so this absurd idea of jars inside jars
    isn't even helpful.Dang DrClap, you seem to be the go-to guy for destroying all my ridiculous ideas (no offense; I mean that in a good way).
    Seems I did not understand JWS fully when I thought of that idea. I researched it more after reading the replies here, and I see that I was indeed thinking absurdly.
    Thank you for the help,
    Dan

  • JARs inside my JAR

    Hi Folks,
    I'm creating a JAR file for my application. My app uses another JAR file and I want to package it inside my jar.
    I tried to use "Path-Class" attribute in MANIFEST.MF file but without success.
    Any help would be appreciate.
    TIA.
    Romualdo Rubens de Freitas

    I wonder how you missed to recognize that jars DO contain jars for four years, as you subscribed in 2001.
    Of course the standard class loader cannot handle jars in jars, but many solutions do exist for this problem. (It was really a problem, since almost all java applications are required to ship with jars inside jars).
    The best solution I encountered, is the fat_jar plugin for eclipse. If you are not an eclipse user try ONEJar.
    Being silent is sometimes better than to provide non-solutions for problems for which solutions exist.

  • JAR using another JAR

    Hi,
    I have created in Eclipse simple class Blah.class:
    public class Blah {
         public Blah() {
              System.out.println("Inside blah");
    Then I made a JAR file: C:\Blah.jar
    Then I made in Eclipse another project with a simple class BlahBlah.class and linked Blah.jar file in this project:
    public class BlahBlah {
         public BlahBlah() {
              System.out.println("Inside BlahBlah");
              Blah b = new Blah();
         public static void main(String arg[]) {
              BlahBlah bl = new BlahBlah();
    Then I made another JAR file C:\MyJar\BlahBlah.jar from this project as an executable JAR.
    But when I tried to run the second JAR from command line bad things happened. This is the output:
    C:\MyJar>java -jar BlahBlah.jar
    Inside BlahBlah
    Exception in thread "main" java.lang.NoClassDefFoundError: Blah
    at BlahBlah.<init>(BlahBlah.java:5)
    at BlahBlah.main(BlahBlah.java:8)
    Java execution started, but first JAR (C:\Blah.jar) was not found. In CLASSPATH variable I have following value: C:\Blah.jar
    So, what am I doing wrong?
    Thanks in advance. Lokutus.

    When executing a jar, that jar has a personal classpath if I'm not mistaken, the CLASSPATH variable is ignored (which is logical, because only your system has that classpath. When executing the jar on another system you want the jar to execute without any environment variables being needed).
    I know that in the META-INF/MANIFEST.MF file inside the executable jar you can list jar files that the executable jar depends on. The line would look like:
    Class-Path: jar1.jar jar2.jar
    and so forth (seperate by a space). What I don't know is how to make the mkjar tool create this line... google is probably your best friend.

  • Jar inside a jar

    I would like to insert a jar (jar1) into another jar (jar2). I have extract all files of jar1 and then I construct jar2. But then when I click on jar2 I have the following message : "Could not find the main class".Is there something to add to the manifest? My manifest only gives the main class of jar2.

    http://forum.java.sun.com/thread.jsp?forum=22&thread=405160&tstart=0&trange=100

  • Pass a object from one jar to another jar file

    I have a common jar file which will communicate to the server for data validation purpose.But after validation it has to invoke different different jar file based on its response from the server.So, I might have a object which has to pass from the common jar file to a specific jar file.So, I like to know what will be the best procedure to achieve it.
    Please help me out.

    arpitak wrote:
    Yes,jar file holds class files.one of class files wants to trigger a method of a class file which resides in different jar file.this is the situation I tried to describe.Let consider there are three jar files like JAR A,JAR B ,JAR C.Here JAR A is a common jar where other two jar could be used as a plug in. So based on the condition any one of them (JARS) will be triggered by the common jar(JAR A).this is the situation.The class file of JAR A will trigger some method or main method of the JAR B/JAR C.So,here how could I pass a object from one jar to another is my main question.
    Is it clear now?
    I need a solution for this very urgently.Are you looking for a plug-in framework? That is, dynamically discovering and loading plugins. I am not experienced in developing or using plugins. However Googling "java plugin" brings up JPF.
    If you just have multiple jars that have different classes, the JVM will load the appropriate classes if it can find the jars through the standard classloader on the classpath or through a customer classloader.

  • Accessing a jar from another jar

    Please help. I am attempting to access a jdbc driver in a sqlserver.jar file from my own jar file. I can run it fine from code, but when I create my jar file I get a ClassNotFoundException. I know I must be doing something wrong in my jar creation or in my jar manifest file. I am using Forte for Java if that helps. Thanks in advance for any suggestions!

    Thanks for the help guys. I finally got it going. Apparently the sqlserver.jar I was referencing in turn referenced other jar files that I also needed to include in my manifest. Even though all of the jars were in my classpath, I couldn't make it run using %classpath%. Thanks again for the input!

  • Loading jars inside jars

    I'm currently building a console launcher that automatically fetches the console UI classes from servers and then caches them to client machine. User can then launch console UIs of different kinds of servers using unified launcher.
    My problem is that most of the console UIs are dependant of other libraries and extracting these libs inside the UI jar is not an option. I've tried to package all jars including the console UI application itself into a another jar but hitting the wall currently when I try to accomplish something like this:
    1. Check if disk cache already contains the jar file with md5
    2. If not fetch the jar to disk
    3. Open the jar file
    4. Fetch all jars inside the jar and pass them to new classloader from classloaderpool <- This is where i hit the wall as I can't figure how to make the classloading of jars inside another jar.
    It seems that i can't create JarFile instances from inputstreams but only from specified filenames.
    I tried to use uberjar from codehaus but couldn't figure how to instantiate the main class of the console ui with parameters from inside another application.

    I suddenly find myself with a similar problem. My app is deployed with webstart, but I need to put a jar file in there (edtftpj-1.3.2.jar) so it can use FTP. Where do I put it? Right now it's inside a lib directory, but it's not getting found by the app that calls it.
    Help?
    --- Eric

  • Adding Jar files in another Jar file

    Hi,
    I have a very bad problem. Please some one help me here.
    I created a Java application which is organized in a package structure.
    The directories and files in the JAr files are following
    1) TestApplication.class - The application startup class.
    2) com(dir) - The start of my package structure, all the othere files are in this directory
    3) config (dir) - Directory containing all the configuration files.
    4) hsqlDatabase (dir) - contains the inprocess database
    5) images (dir) - Contains all the images used in the application.
    6) lib (dir) - Contains all the other jar files that i use in this application, i have about 10 of them in this directory.
    I created a jar file which contains all these dir and the TestApplication.class file. I also uses the 'Main-Class' and 'Class-Path' attribute.
    This is my META-INF\MANIFEST.MF file
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.1
    Created-By: 1.4.2_03-b02 (Sun Microsystems Inc.)
    Built-By: jj
    Main-Class: TestApplication
    Class-Path: .;./lib/commons-codec-1.3.jar;./lib/commons-httpclient-3.0
    -alpha1.jar;./lib/hsqldb.jar;./lib/kunststoff-2_0_1.jar;./lib/kunstst
    off.jar;./lib/liquidlnf.jar;./lib/log4j-1.2.8.jar;./lib/looks-1.2.2.j
    ar;./lib/jcalendar.jar;./lib/mysql-connector-java-3.0.9-stable-bin.ja
    r;./lib/ViolinStrings.jar;./config;./hsqlDatabase;./images
    When i try to run the application through
    java -jar xxxxx.jar
    1) the first problem is that it starts the application (TestApplication.class) and also loads the rest of the application in my package(com\...). But it cannot find the classes which are in the jar file (in the lib dir).
    2) I am also trying to read from a config\xxxxx.properties file, but i get an exception showing FileNotFound (xxxxx.properties).
    Hope that this will help you to help with my problem,
    Thanks in advance,
    Jobby

    1) the first problem is that it starts the
    application (TestApplication.class) and also loads
    the rest of the application in my package(com\...).
    But it cannot find the classes which are in the jar
    file (in the lib dir).
    jars inside of jars do not work like you want them too. You should be able to write a class loader that can find those other jars, but Java does not directly support jars inside of jars. Of course, you can unjar the other jars and use them as well.
    2) I am also trying to read from a
    config\xxxxx.properties file, but i get an exception
    showing FileNotFound (xxxxx.properties).
    Is this file also in the jar? If it is, you need to use getClass().getResource() to find the file.

  • Is it possible to extract out the jars in XMLConnector.jar?

    Hi all,
    I've currently got Crystal Reports working properly in my Java Web project, which is using an XML Datasource if I include XMLConnector.jar in my WEB-INF/lib folder. However, we don't want to have to include this rather large jar in our project as it contains many jars that we already have.
    I tried to extract out the jars inside XMLConnector.jar into my WEB-INF/lib folder, but now I get the same exception as if I had not included XMLConnector.jar:
    com.crystaldecisions.reports.common.QueryEngineException: Error loading database connector. The class 'com.crystaldecisions.reports.queryengine.driverImpl.DriverLoader' could not be accessed.
    Caused by: com.businessobjects.reports.jdbinterface.common.DBException: Failed to load the database connector 'crdb_xml.dll'.
    Is there a way to diassociate the contents inside this jar, or if you can help me locate the exact libraries that are required to properly load XML datasources, and any settings I need to change.
    Thanks,
    Peter

    The XMLConnector.jar is a jar of jars.
    There are some Java Web Application Servers that have issues with unjarring jar of jars for the jars within.
    So for those deployments, I do recommend unjarring XMLConnector.jar.
    For a Web App, you'd put the jars in the jar in the WEB-INF/lib folder, and other content within WEB-INF/classes. This because there's no special handling of a jar of jars - the CRJ engine merely asks the classloader to handle the loading.
    Sincerely,
    Ted Ueda

  • Extension jars within a jar

    hi
    i was just wondering whether it is possible to have (download) extension jars inside a jar file so you could distribute just a single file? if it is possible how would you refer to them in the manifest?
    cheers
    andy

    why not?
    1. extract other .jar file
    2. add extracted files to your own one jar.
    distribute the last .jar file..
    The following may help you..
    JavaJar(written by java) can compress and decompress jar,war, ear and.zip...
    may download from http://www.qwerks.com/download/4114/JavaJar.zip
    the tool is very verygood tool.
    but the homepage(www.pivotonic.com) of JavaJar cannot be accessed.
    it is funny.
    good lucky.

  • Referencing a jar inside an ear

    Hi,
    I have a program where I need to get a reference to a jar inside an ear
    file. For example, I have this variable set:
    $WL_HOME/config/mydomain/applications/test.ear and I want to set a variable
    for a jar inside this ear.
    Does anyone know the best way to do that?
    Thanks

    When you say "set a variable", do you mean read an XML or properties file
    and modify it and write it back?
    It is relatively simple using the java.util.zip / java.util.jar packages.
    Editing XML is a little harder; I would suggest relying on something like
    JDOM or the libs from The Mind Electric.
    Peace,
    Cameron Purdy
    Tangosol Inc.
    Tangosol Coherence: Clustered Coherent Cache for J2EE
    Information at http://www.tangosol.com/
    "Diane Curley" <[email protected]> wrote in message
    news:[email protected]..
    Hi,
    I have a program where I need to get a reference to a jar inside an ear
    file. For example, I have this variable set:
    $WL_HOME/config/mydomain/applications/test.ear and I want to set avariable
    for a jar inside this ear.
    Does anyone know the best way to do that?
    Thanks

  • Call class inside a jar file??

    Hello group,
    I have a class with a main mathod and this class is inside a .jar file. This jar file reside under my
    web-inf\lib or class-path directory in my application at Weblogic Server.
    How can I call this class by command line?
    I have to create a cliente to do it?
    Is it possible? I´m having problems because the weblogic server is using the jar file at the same time that I trying use it calling by command line.
    Where can I find more information?
    Message was edited by:
    Denimar

    Authcloud9981 wrote:
    Hi I have an executible JAR file that I can call from command line by using the command - "java -jar file.jar".
    Is there a way for me to call this JAR file inside a Java class in another Java Program?There can be more going on in a jar than just as a container for classes.
    The manifest defines the behavior. So to replicate the behavior you must do exactly that.
    As an example of that.
    [http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html#download]
    Additionally by running it in your application you must consider what the scope of that is. If you just load the classes directly then they will be in the system class loader and thus cannot be unloaded. Using a class loader solves that.

  • Classpath to .jars inside .zip files

    I had post something similar to this but this time it's another idea (and another problem) - so, this is not cross-posting.
    I have this .zip file with 25 .jar files, I want to use it in my Manifest file, but it seems that when the classes are in the .jars and the .jars are in a zip file they are not reached by the Classloader.
    #  Archive Libs.zip*
    commons-collections-3.1.jar
    commons-digester.jar
    commons-lang-2.0.jar
    commons-logging-1.0.3.jar
    commons-logging.jar
    commons-logging-api.jar
    commons-net-1.4.1.jar
    firebirdsql-full.jar
    formsrt.jar
    itext-1.3.1.jar
    jasperreports-1.3.1.jar
    jaybird-2.1.1.jar
    jaybird-full-2.1.1.jar
    jcommon-1.0.0-rc1.jar
    jdt-compiler.jar
    jfreechart-1.0.0-rc1.jar
    Lib.jar
    log4j-1.2.14.jar
    looks-1.3.1.jar
    mail.jar
    pop3.jar
    substance-lite.jar
    swingx-0.8.0.jar
    activation.jar
    commons-beanutils.jar12670124 10779634 25
    The file MANIFEST.MF
    Manifest-Version: 1.0
    Specification-Version: 3
    Implementation-Version: 0 2007
    Implementation-Title: SikGraf(Standard)
    Specification-Vendor: Kooky
    Created-By: Kooky
    Main-Class: com.sikgraf.main.Main
    SplashScreen-Image: com/sikgraf/imagens/siggraf.jpg
    Class-Path: . \SikGrafStandard.jar \C:/Kooky/SigGraf/Libs.zip[/code]
    Is is possible to do that? (.jars inside a zip) Or am I dreaming here?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You would have to write your own custom classloader to do this, which is what http://one-jar.sourceforge.net/ tries to do.

Maybe you are looking for

  • Does Classic report provide facility to make report total to be hyperlink

    Hi , Does Classic report in apex provide provision to make the report-total row editable(hyperlinked) ? if so how to implement that. Acq     WIP     Closed Abc     1     3 Def     2     5 report total :     3     8 Also is it possible to provide more

  • Invoking a Web Service using XI 2.0

    Hi all, I am attempting to create a scenario where an SAP application invokes a web service through XI 2.0. I have created an ABAP proxy to allow my ABAP to start the call process and have set up the message interfaces within the Integration Director

  • Itunes wont open/ file icon on ipod- NEED HELP ASAP!

    My itunes will not open at all on my comp. I downloaded the newest version, then nothing would open. I removed all versions and attempted to re-install again. Now, my ipod will not turn on. There is a file icon with an exclamation point. I dont know

  • How can i edit an iMove someone has sent me via email?

    A colleague was working on an iMove trailer today and asked if I would do a bit of work on it at home. They emailed it to me but now now when i open it up it just plays through quicktime. I really want to get it into iMovie to edit it a bit... any su

  • Trying to recover  files that are m2v and aiffs

    I've experienced my first external hd crash, and the only files i've left of several pieces are separated m2v and aiff that had been made for DVD StudioPro. I'm trying to recover those files so that I can remake masters, and I'm having a heck of a ti