Here you can find the source of getClassLoaderFromPaths(ArrayList
public static ClassLoader getClassLoaderFromPaths(ArrayList<Path> paths)
//package com.java2s; //License from project: Open Source License import java.nio.file.Path; import java.net.URLClassLoader; import java.net.URL; import java.net.MalformedURLException; import java.util.ArrayList; public class Main { public static ClassLoader getClassLoaderFromPaths(ArrayList<Path> paths) { ArrayList<URL> urls = new ArrayList<URL>(); // for each unzipped project, we need to load the class, this feed the ClassLoader with the // path in URL for (Path p : paths) { try { URL url = p.toUri().toURL(); urls.add(url);// w w w . j av a 2 s. c o m } catch (MalformedURLException e) { e.printStackTrace(); } } URL[] urlsArray = new URL[urls.size()]; // load the test classes from these directories urlsArray = urls.toArray(urlsArray); // JVM is not allowed to blindly downcast, so we pass in the object as desired cast ClassLoader cl = new URLClassLoader(urlsArray); return cl; } }