5 Replies Latest reply: Nov 21, 2008 8:49 AM by JoachimSauer RSS

    Jar file containing other Jar files

      Hi all, I am trying to relase an app that requires jdom.jar within my own jar file.

      My App works perfectly within Eclipse as it's included in the Referenced Libs however, when I Export "App Client Jar File" the code is unable to include this classpath.
      The jdom.jar file is included into my original jar file but it does not find it?

      I know I can ask the users to include the jdom.jar into their class path but this app is going to be used on loads of computers. I also want the install of this app to be as quick and easy as possible. Dropping a Jar file onto the Desktop seamed the best option to me?

      Can anyone give the a good method of releasing my app with references included or any other release methods I am not aware of?

        • 1. Re: Jar file containing other Jar files
          Including one Jar in another won't work (at least not in the way you want it to).

          What you need to do is to store all jar files (yours and the libraries) in some fixed relation to each other (possibly all in the same directory for example) and set the classpath property in the MANIFEST.MF to refer to the required jar files.
          • 2. Re: Jar file containing other Jar files
            First tell us where are you putting your jar files?
            You can keep your jars with utility jars.
            e.g. xyz.jar is your jar file
            jdom.jar is utility jar
            both can coexist at same location and

            and now set the class path of lib directory.
            • 3. Re: Jar file containing other Jar files
              Hi Guys, don;t laugh I am new :)

              I have created am src folder that contains all my code in appropirate packages


              I simple dragged and droped the JDOM.jar file from the desktop (After downloading) onto the "Referenced Libararies" section within Eclipes "Package Explorer.

              When I do an export I get the following structure.

              (etc etc)

              I can see that the export has moved the jom.jar file into my Jar file but this is not being found within the class path.

              Do I need to create another project that includes my Jar file, JDOM.Jar and a custom Main.java. Then export this as a Jar file??? Seams a bit strange?
              • 4. Re: Jar file containing other Jar files
                I have worked it out. I was using the wrong "Export" type within Eclipse (Sorry this ended up not being Java related)

                For reference:
                To export when including other Jar files select "Export" | "Java" | "Runnable Jar File"
                Select your "Launch Configuration"
                click finish

                Make sure that the Jar files are includinged within your "Launch Configuration" Class Path under "Edit Configuration" and if done.

                PS guys, do you know of any other method of releasing a Java app?
                • 5. Re: Jar file containing other Jar files
                  WebStart / JNLP. It's more powerful, but a lot more complicated as well.