public class ClassTest {
  public static void main(String args[]){

    // get parameter
    if (args.length != 2){
      System.out.println("usage: java Test <class> <inpstring>");
      System.exit(0);
    }
    String strClassName = args[0];
    String arg = args[1];

    // first, get the class template for the requested object
    Class oclsPlugin = null;
    try {
      oclsPlugin = Class.forName(strClassName);
    } catch (ClassNotFoundException e){
      System.out.println("class not found: " + strClassName);
      System.exit(1);
    }

    // then create an object instance out of the class template and try
    // to cast it to the desired interface
    IPlugin oPlugin = null;
    try {
      Object o = oclsPlugin.newInstance();
      if (o instanceof IPlugin){
        oPlugin = (IPlugin)o;
      } else {
        System.out.println(strClassName + " does not support IPLugin interface");
        System.exit(1);
      }
    } catch (InstantiationException e){
      System.out.println("class not instantiated: " + strClassName);
      System.exit(1);
    } catch (IllegalAccessException e){
      System.out.println("class not accessible: "+ strClassName);
      System.exit(1);
    }

    // execute a test method on the created object
    String strResult = oPlugin.execute(arg);
    System.out.println("Ergebnis: " + strResult);

  }
}

