code: private static URL[] getJarURLs(File dir) throws GuacamoleException {
  
          // Validate directory is indeed a directory
          if (!dir.isDirectory())
              throw new GuacamoleException(dir + " is not a directory.");
  
          // Get list of URLs for all .jar's in the lib directory
          Collection<URL> jarURLs = new ArrayList<URL>();
          File[] files = dir.listFiles(new FilenameFilter() {
  
              @Override
              public boolean accept(File dir, String name) {
  
                  // If it ends with .jar, accept the file
                  return name.endsWith(".jar");
  
              }
  
          });
  
          // Verify directory was successfully read
          if (files == null)
              throw new GuacamoleException("Unable to read contents of directory " + dir);
  
          // Add the URL for each .jar to the jar URL list
          for (File file : files) {
  
              try {
                  jarURLs.add(file.toURI().toURL());
              }
              catch (MalformedURLException e) {
                  throw new GuacamoleException(e);
              }
  
          }
  
          // Set delegate classloader to new URLClassLoader which loads from the .jars found above.
          URL[] urls = new URL[jarURLs.size()];
          return jarURLs.toArray(urls);
  
      }
docs: Returns all .jar files within the given directory as an array of URLs.
  
  @param dir
  The directory to retrieve all .jar files from.
  
  @return
  An array of the URLs of all .jar files within the given directory.
  
  @throws GuacamoleException
  If the given file is not a directory, or the contents of the given
  directory cannot be read.