Popular Posts
jQuery Validation Engine default options Create web service client cross SSL with eclipse When creating web service cross SSL using eclipse, it occuss some error like below: And it can't build the client source from this wa... Screen capture import java.awt.AWTException; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import j...
Stats
Dynamic add classpath path
public void appendClasspath(String path) throws NoSuchMethodException, MalformedURLException, InvocationTargetException, IllegalAccessException {
    Path externalResourcesFolder = Paths.get(path);
    ClassLoader sysLoader = ClassLoader.getSystemClassLoader();
    if (sysLoader instanceof URLClassLoader) {
        Class<URLClassLoader> sysLoaderClass = URLClassLoader.class;

        // Use reflection to invoke the private addURL method
        Method method = sysLoaderClass.getDeclaredMethod("addURL", URL.class);
        method.setAccessible(true);
        method.invoke(sysLoader, externalResourcesFolder.toUri().toURL());

        System.out.printf("classpath: %s loaded%n", path);
    }
}