home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / Main3.java < prev    next >
Text File  |  1997-09-06  |  988b  |  34 lines

  1. /*
  2.  *  Main3.java
  3.  *
  4.  *  Use reflection to get a Class object of class Hello3 and
  5.  *  create an instance of it.  Get a Method object that will
  6.  *  invoke the method printHello() of class Hello.  Note that
  7.  *  with this code, the user does not need to link in the code
  8.  *  from Hello3.java during compilation.  The user, however,
  9.  *  will have to register Hello3.dll first using the snjreg
  10.  *  tool before running this code.
  11.  */
  12.  
  13. package samples.dynamicDLL;
  14.  
  15. import java.lang.reflect.*;
  16.  
  17. public class Main3
  18. {
  19.     public static void main( String args[] )
  20.     {
  21.         try
  22.         {
  23.             Class someClass = Class.forName( "samples.dynamicDLL.Hello3" );
  24.             Object someObject = someClass.newInstance();
  25.             Method someMethod = someClass.getMethod( "printHello", null );
  26.             someMethod.invoke( someObject, null );
  27.         }
  28.         catch( Exception e )
  29.         {
  30.             System.out.println( e.toString() );
  31.         }
  32.     }
  33. }
  34.