Suppose I want to dynamically load a class in java and call its start() (has no parameters):
start()
Class<?> c = Class.forName("AbuseMe"); c.getMethod("start").invoke(c.newInstance());
Would this be a good / safe way to do this?
Looks nice.
If you do a lot of reflection-related code, you can look at Apache Beanutils or Apache OGNL or something similar.
Reflection is a very useful approach for working with a Java class at runtime; it can be used to load a Java class, call its methods, or analyze the class at runtime.
Try this example.
This will help you.
How to use reflection to call a Java method at runtime
thanks