Java tutorial
//package com.java2s; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; public class Main { public static Object newHandlerInstance(String clzPath, Class<?>[] parameterTypes, Object[] args) { try { Class<?> clz = Class.forName(clzPath); Constructor<?> constructor = clz.getConstructor(parameterTypes); return constructor.newInstance(args); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; } }