Example usage for java.net URLClassLoader getURLs

List of usage examples for java.net URLClassLoader getURLs

Introduction

In this page you can find the example usage for java.net URLClassLoader getURLs.

Prototype

public URL[] getURLs() 

Source Link

Document

Returns the search path of URLs for loading classes and resources.

Usage

From source file:xc.mst.utils.SetupClasspath.java

@SuppressWarnings("unchecked")
public static void addURL(URL u) {

    URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
    Class sysclass = URLClassLoader.class;

    for (URL u2 : sysloader.getURLs()) {
        // System.out.println("u: "+u2);
    }//from   ww w. ja va 2  s. com

    try {
        Method method = sysclass.getDeclaredMethod("addURL", new Class[] { URL.class });
        method.setAccessible(true);
        method.invoke(sysloader, new Object[] { u });
    } catch (Throwable t) {
        t.printStackTrace();
        throw new RuntimeException("Error, could not add URL to system classloader");
    }

}