Here you can find the source of createClassPath(File file)
public static URL[] createClassPath(File file) throws Exception
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FilenameFilter; import java.net.URL; public class Main { public static URL[] createClassPath(File file) throws Exception { URL[] urls = null;// w ww .j av a 2s . c om if ((file.exists()) && (file.isDirectory())) { String[] jars = file.list(new FilenameFilter() { public boolean accept(File dir, String name) { if (name.endsWith(".jar")) { return true; } return false; } }); if (jars.length != 0) { urls = new URL[jars.length]; for (int i = 0; i < jars.length; i++) { urls[i] = new File(file.getAbsolutePath(), jars[i]) .toURI().toURL(); } } } else if ((file.exists()) && (!file.isDirectory())) { if (file.getName().endsWith(".jar")) { urls = new URL[] { file.toURI().toURL() }; } } return urls; } }