I'm trying to implement dynamic class loading using:
Class.forName(className, true, Thread.currentThread().getContextClassLoader());
Class A (which is a jar file residing in the /jre/lib/ext dir ) that I'm loading extends class B (which is packaged as a separate package with the main application). Next I invoke a method defined in class B, which class A should have access to (it being class B's child). So I do:
classInstance = classLoaded.newInstance();
Method M = classA.getMethod("methodNameinClassB", null);
M.invoke(classInstance, null);
When I execute my main class, I get the error about noSuchMethod. What am I doing wrong?
Class.forName(className, true, Thread.currentThread().getContextClassLoader());
Class A (which is a jar file residing in the /jre/lib/ext dir ) that I'm loading extends class B (which is packaged as a separate package with the main application). Next I invoke a method defined in class B, which class A should have access to (it being class B's child). So I do:
classInstance = classLoaded.newInstance();
Method M = classA.getMethod("methodNameinClassB", null);
M.invoke(classInstance, null);
When I execute my main class, I get the error about noSuchMethod. What am I doing wrong?