Here you can find the source of createClassLoader(final String[] cpEntries)
Parameter | Description |
---|---|
cpEntries | classpath entries |
public static ClassLoader createClassLoader(final String[] cpEntries)
//package com.java2s; // License as published by the Free Software Foundation; either import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; public class Main { /**/*w w w . j a va 2s .c o m*/ * Builds a ClassLoader for a given classpath. * @param cpEntries classpath entries * @return the new ClassLoader */ public static ClassLoader createClassLoader(final String[] cpEntries) { final URL[] cpUrls = new URL[cpEntries.length]; for (int i = 0; i < cpEntries.length; i++) { String cpEntry = cpEntries[i]; File entry = new File(cpEntry); try { URL url = entry.toURI().toURL(); cpUrls[i] = url; } catch (MalformedURLException ex) { throw new IllegalArgumentException("Cannot create classLoader from classpath entry " + entry, ex); } } final URLClassLoader classPathLoader = new URLClassLoader(cpUrls); return classPathLoader; } }