static URL[] constructUrlsFromClasspath(String classpath)
      throws MalformedURLException {
    List<URL> urls = new ArrayList<URL>();
    for (String element : classpath.split(File.pathSeparator)) {
      if (element.endsWith(File.separator + "*")) {
        List<Path> jars = FileUtil.getJarsInDirectory(element);
        if (!jars.isEmpty()) {
          for (Path jar: jars) {
            urls.add(jar.toUri().toURL());
          }
        }
      } else {
        File file = new File(element);
        if (file.exists()) {
          urls.add(new File(element).toURI().toURL());
        }
      }
    }
    return urls.toArray(new URL[urls.size()]);
  }
@Test
  public void testConstructUrlsFromClasspath() throws Exception {
    File file = new File(testDir, "file");
    assertTrue("Create file", file.createNewFile());

    File dir = new File(testDir, "dir");
    assertTrue("Make dir", dir.mkdir());

    File jarsDir = new File(testDir, "jarsdir");
    assertTrue("Make jarsDir", jarsDir.mkdir());
    File nonJarFile = new File(jarsDir, "nonjar");
    assertTrue("Create non-jar file", nonJarFile.createNewFile());
    File jarFile = new File(jarsDir, "a.jar");
    assertTrue("Create jar file", jarFile.createNewFile());

    File nofile = new File(testDir, "nofile");
    // don't create nofile

    StringBuilder cp = new StringBuilder();
    cp.append(file.getAbsolutePath()).append(File.pathSeparator)
      .append(dir.getAbsolutePath()).append(File.pathSeparator)
      .append(jarsDir.getAbsolutePath() + "/*").append(File.pathSeparator)
      .append(nofile.getAbsolutePath()).append(File.pathSeparator)
      .append(nofile.getAbsolutePath() + "/*").append(File.pathSeparator);
    
    URL[] urls = constructUrlsFromClasspath(cp.toString());
    
    assertEquals(3, urls.length);
    assertEquals(file.toURI().toURL(), urls[0]);
    assertEquals(dir.toURI().toURL(), urls[1]);
    assertEquals(jarFile.toURI().toURL(), urls[2]);
    // nofile should be ignored
  }