home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-09-06 | 988 b | 34 lines |
- /*
- * Main3.java
- *
- * Use reflection to get a Class object of class Hello3 and
- * create an instance of it. Get a Method object that will
- * invoke the method printHello() of class Hello. Note that
- * with this code, the user does not need to link in the code
- * from Hello3.java during compilation. The user, however,
- * will have to register Hello3.dll first using the snjreg
- * tool before running this code.
- */
-
- package samples.dynamicDLL;
-
- import java.lang.reflect.*;
-
- public class Main3
- {
- public static void main( String args[] )
- {
- try
- {
- Class someClass = Class.forName( "samples.dynamicDLL.Hello3" );
- Object someObject = someClass.newInstance();
- Method someMethod = someClass.getMethod( "printHello", null );
- someMethod.invoke( someObject, null );
- }
- catch( Exception e )
- {
- System.out.println( e.toString() );
- }
- }
- }
-