FileDocCategorySizeDatePackage
Invoke.javaAPI DocExample893Mon May 01 14:41:40 BST 2000None

Invoke

public class Invoke extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    try {
      Class c = Class.forName( args[0] );
      Method m = c.getMethod( args[1], new Class [] { } );
      Object ret =  m.invoke( null, null );
      System.out.println(
          "Invoked static method: " + args[1]
          + " of class: " + args[0]
          + " with no args\nResults: " + ret );
    } catch ( ClassNotFoundException e ) {
      // Class.forName(  ) can't find the class
    } catch ( NoSuchMethodException e2 ) {
      // that method doesn't exist
    } catch ( IllegalAccessException e3 ) {
      // we don't have permission to invoke that method
    } catch ( InvocationTargetException e4 ) {
      // an exception ocurred while invoking that method
      System.out.println(
          "Method threw an: " + e4.getTargetException(  ) );
    }