import source from 1.3.40
[external/swig.git] / Examples / java / funcptr / runme.java
1
2 public class runme {
3
4   static {
5     try {
6         System.loadLibrary("example");
7     } catch (UnsatisfiedLinkError e) {
8       System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
9       System.exit(1);
10     }
11   }
12
13   public static void main(String argv[]) {
14
15
16     int a = 37;
17     int b = 42;
18
19     // Now call our C function with a bunch of callbacks
20
21     System.out.println( "Trying some C callback functions" );
22     System.out.println( "    a        = " + a );
23     System.out.println( "    b        = " + b );
24     System.out.println( "    ADD(a,b) = " + example.do_op(a,b,example.ADD) );
25     System.out.println( "    SUB(a,b) = " + example.do_op(a,b,example.SUB) );
26     System.out.println( "    MUL(a,b) = " + example.do_op(a,b,example.MUL) );
27
28     System.out.println( "Here is what the C callback function classes are called in Java" );
29     System.out.println( "    ADD      = " + example.ADD.getClass().getName() );
30     System.out.println( "    SUB      = " + example.SUB.getClass().getName() );
31     System.out.println( "    MUL      = " + example.MUL.getClass().getName() );
32   }
33 }