code: public static void unJar(File jarFile, File toDir) throws IOException {
      JarFile jar = new JarFile(jarFile);
      try {
        Enumeration entries = jar.entries();
        while (entries.hasMoreElements()) {
          JarEntry entry = (JarEntry)entries.nextElement();
          if (!entry.isDirectory()) {
            InputStream in = jar.getInputStream(entry);
            try {
              File file = new File(toDir, entry.getName());
              if (!file.getParentFile().mkdirs()) {
                if (!file.getParentFile().isDirectory()) {
                  throw new IOException("Mkdirs failed to create " + 
                                        file.getParentFile().toString());
                }
              }
              OutputStream out = new FileOutputStream(file);
              try {
                byte[] buffer = new byte[8192];
                int i;
                while ((i = in.read(buffer)) != -1) {
                  out.write(buffer, 0, i);
                }
              } finally {
                out.close();
              }
            } finally {
              in.close();
            }
          }
        }
      } finally {
        jar.close();
      }
    }
docs: Unpack a jar file into a directory.