Skip to content

Instantly share code, notes, and snippets.

@cyberdak
Last active September 3, 2016 01:09
Show Gist options
  • Select an option

  • Save cyberdak/d09aff12f448c3b8c51523c5667f977e to your computer and use it in GitHub Desktop.

Select an option

Save cyberdak/d09aff12f448c3b8c51523c5667f977e to your computer and use it in GitHub Desktop.
network class loader test
package com.cyberdak.stringsearch;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
public class Networ {
public static void main(String[] args) throws Exception {
URLClassLoader loader = new URLClassLoader(new URL[]{new URL("http://localhost:8080/")});
Class c = loader.loadClass("Test");
Object o = c.newInstance();
Method m = c.getMethod("testFunction", null);
m.invoke(o, null);
}
}
test con
test function
public class Test {
public void testFunction(){
System.out.println("test function");
}
public Test(){
System.out.println("test con");
}
public static void main(String[] args) {
System.out.println("main");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment