private static void createJar(File dir, File jarFile) throws IOException {
    Preconditions.checkNotNull(dir, "dir");
    Preconditions.checkNotNull(jarFile, "jarFile");
    File jarDir = jarFile.getParentFile();
    if (!jarDir.exists()) {
      if (!jarDir.mkdirs()) {
        throw new IOException(MessageFormat.format("could not create dir [{0}]", jarDir));
      }
    }
    try (FileOutputStream fos = new FileOutputStream(jarFile);
      JarOutputStream jos = new JarOutputStream(fos)) {
      jarDir(dir, "", jos);
    }
  }
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