Here it is using Java reflection:
try {
Class<?> myClass = Class.forName("Foo");
Method myMethod = myClass.getMethod("bar");
Object retObject = myMethod.invoke(null);
} catch (Exception e) {
// handle errors here...
e.printStackTrace();
}
This is if bar()
is a static method here, and if it has no parameter.
See this tutorial for more information on reflection.