code: public static void main(String args[]) {
      // args = new String[] { "C:/Temp/merged.jar", "C:/jdk1.5.0/jre/lib/ext/dnsns.jar",  "/Temp/addtojar2.log", "C:/jdk1.5.0/jre/lib/ext/mtest.jar", "C:/Temp/base"};
      if (args.length < 2) {
        System.err.println("Usage: JarFiles merged.jar [src.jar | dir | file ]+");
      } else {
        JarBuilder jarFiles = new JarBuilder();
        List names = new ArrayList();
        List unjar = new ArrayList();
        for (int i = 1; i < args.length; i++) {
          String f = args[i];
          String ext = jarFiles.fileExtension(f);
          boolean expandAsJar = ext.equals("jar") || ext.equals("zip");
          if (expandAsJar) {
            unjar.add(f);
          } else {
            names.add(f);
          }
        }
        try {
          jarFiles.merge(names, unjar, args[0]);
          Date lastMod = new Date(new File(args[0]).lastModified());
          System.out.println("Merge done to " + args[0] + " " + lastMod);
        } catch (Exception ge) {
          ge.printStackTrace(System.err);
        }
      }
    }
docs: Test program