Java Reflection – Object is not an instance of declaring class

You’re invoking the method with the class, but you need an instance of it. Try this:

serverMethod.invoke(base.newInstance(), new HashMap<String, String>());

Leave a Comment