Class.forName() on inner classes
807605Jun 16 2007 — edited Jun 16 2007I am attempting to do something like this:
class A {
...
static class B {
...
}
}
B ojb = (B)createObject(A.B)
...
public static Object createObject(String className) throws ClassNotFoundException {
Object object = null;
try {
Class classDefinition = Class.forName(className);
JOptionPane.showMessageDialog(null,"got here");
object = classDefinition.newInstance();
JOptionPane.showMessageDialog(null,"got here2");
} catch (InstantiationException e) {
System.out.println(e);
} catch (IllegalAccessException e) {
System.out.println(e);
}
JOptionPane.showMessageDialog(null,"got here 3");
return object;
}
The method executes and returns fine but when I attempt to perform the cast, I get a the classNotFoundException. What would be causing it?