code: private static void addHiveSiteDirToClasspath(String hiveSiteDir) {
      LOG.info("Adding " + hiveSiteDir + " to CLASSPATH");
      File f = new File(hiveSiteDir);
      try {
        URL u = f.toURI().toURL();
        URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
        Class<URLClassLoader> urlClass = URLClassLoader.class;
        Method method = urlClass.getDeclaredMethod("addURL", new Class[] { URL.class });
        method.setAccessible(true);
        method.invoke(urlClassLoader, new Object[] { u });
      } catch (ReflectiveOperationException | IOException e) {
        throw new RuntimeException("Unable to add hive.site.dir to CLASSPATH", e);
      }
    }
docs: Helper method to add the directory containing the hive-site.xml file to the classpath
  @param hiveSiteDir is the path to to the folder containing the hive-site.xml file