I 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); ...