KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SimpleTest


1 /*
2  * SimpleTest.java
3  *
4  * Created on 01.04.2006.
5  *
6  * Copyright (c) 2005, 2006 Johann Burkard (<mailto:jb@eaio.com>)
7  * <http://eaio.com>
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22  * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25  * USE OR OTHER DEALINGS IN THE SOFTWARE.
26  *
27  */

28 import com.eaio.nativecall.Holder;
29 import com.eaio.nativecall.IntCall;
30 import com.eaio.nativecall.NativeCall;
31 import com.eaio.nativecall.VoidCall;
32
33 /**
34  *
35  * @author <a HREF="mailto:jb@eaio.com">Johann Burkard</a>
36  * @version $Id$
37  */

38 public class SimpleTest {
39
40     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
41
42         if (args.length == 0) {
43             System.out.println(
44                 "Usage: java "
45                     + SimpleTest.class.getName()
46                     + " [path to nctest.dll]");
47             System.exit(1);
48         }
49
50         NativeCall.init();
51
52         IntCall ic = new IntCall(args[0], "_test@4");
53         int x = ic.executeCall(new Integer JavaDoc(42));
54         System.out.println("x = " + x);
55         ic.destroy();
56
57         VoidCall myFunc = new VoidCall(args[0], "_myFunc@12");
58         Holder output1Holder = new Holder(new Integer JavaDoc(0));
59         Holder output2Holder = new Holder(new Integer JavaDoc(0));
60         myFunc.executeCall(
61             new Object JavaDoc[] { new Integer JavaDoc(2), output1Holder, output2Holder });
62         System.out.println(output1Holder.get());
63         System.out.println(output2Holder.get());
64         myFunc.destroy();
65
66     }
67
68 }
69
Popular Tags