Here you can find the source of invokeMethod(String className, String method, Class[] paramTypes, Object obj, Object[] args)
public static Object invokeMethod(String className, String method, Class[] paramTypes, Object obj, Object[] args) throws Exception
//package com.java2s; /*/* w w w. j av a 2 s . c om*/ * Ulm University DUCKS project * * Author: Elmar Schoch <elmar.schoch@uni-ulm.de> * * (C) Copyright 2006, Ulm University, all rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ import java.lang.reflect.Method; public class Main { public static Object invokeMethod(String className, String method, Class[] paramTypes, Object obj, Object[] args) throws Exception { Object result = null; try { Class cls = Class.forName(className); Method m = cls.getMethod(method, paramTypes); result = m.invoke(obj, args); } catch (Exception e) { throw new Exception("Method invoke failed: Class: " + className + " Method: " + method); } return result; } }