Extend your class with ClassLoader and override method findClass()
class CustomClassLoader extends ClassLoader {
String host;
int port;
public Class findClass(String name) {
byte[] b = loadClassData(name);
return defineClass(name, b, 0, b.length);
}
private byte[] loadClassData(String name) {
// load the class data from the connection
}
}
Then to load your class :
Class r = new CustomClassLoader().findClass("com.genius.MyClass");
OR
Class.forName("com.genius.MyClass", true, new CustomClassLoader());
No comments:
Post a Comment
Note: only a member of this blog may post a comment.