code: private static void setClassLoader(File hdConfDir, Configuration conf) 
      throws Exception {
          ClassLoader parent = conf.getClassLoader();
          URL url = hdConfDir.toURI().toURL();
          URL[] urls = new URL[1];
          urls[0] = url;
          ClassLoader classLoader = new URLClassLoader(urls, parent);
          Thread.currentThread().setContextClassLoader(classLoader);
          conf.setClassLoader(classLoader);
      }
docs: Set class loader for current thread and for Confifguration based on
  Hadoop home.
  
  @param hdConfDir Hadoop home directory
  @param conf Hadoop configuration
  @throws MalformedURLException