public static Set<String> getJarFilesByPath(String pathString, Configuration conf) {
    if (org.apache.commons.lang3.StringUtils.isBlank(pathString)) {
      return Collections.emptySet();
    }
    Set<String> result = new HashSet<>();
    String[] paths = pathString.split(",");
    for (final String path : paths) {
      try {
        Path p = new Path(getURI(path));
        FileSystem fs = p.getFileSystem(conf);
        FileStatus fileStatus = fs.getFileStatus(p);
        if (fileStatus.isDirectory()) {
          // add all jar files under the folder
          FileStatus[] files = fs.listStatus(p, new GlobFilter("*.jar"));
          for (FileStatus file : files) {
            result.add(file.getPath().toUri().toString());
          }
        } else {
          result.add(p.toUri().toString());
        }
      } catch (FileNotFoundException fnfe) {
        LOG.error("The jar file path {} does not exist", path);
      } catch (URISyntaxException | IOException e) {
        LOG.error("Invalid file path {}", path, e);
      }
    }
    return result;
  }
Given a path string, get all the jars from the folder or the files themselves.

@param pathString  the path string is the comma-separated path list
@return            the list of the file names in the format of URI formats.
common/src/java/org/apache/hadoop/hive/common/FileUtils.java