private static void zipDir(File dir, String relativePath, ZipOutputStream zos, boolean start)
    throws IOException {
    String[] dirList = dir.list();
    if (dirList == null) {
      return;
    }
    for (String aDirList : dirList) {
      File f = new File(dir, aDirList);
      if (!f.isHidden()) {
        if (f.isDirectory()) {
          if (!start) {
            ZipEntry dirEntry = new ZipEntry(relativePath + f.getName() + "/");
            zos.putNextEntry(dirEntry);
            zos.closeEntry();
          }
          String filePath = f.getPath();
          File file = new File(filePath);
          zipDir(file, relativePath + f.getName() + "/", zos, false);
        } else {
          String path = relativePath + f.getName();
          if (!path.equals(JarFile.MANIFEST_NAME)) {
            ZipEntry anEntry = new ZipEntry(path);
            copyToZipStream(f, anEntry, zos);
          }
        }
      }
    }
  }
Finds the Jar for a class. If the class is in a directory in the classpath, it creates a Jar on
the fly with the contents of the directory and returns the path to that Jar. If a Jar is created,
it is created in the system temporary directory. This file was forked from
hadoop/common/branches/branch-2@1377176.
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/JarFinder.java