开发者

Creating objects of a Class in a dll in Java

There is a third part dll with definitions of a class in C++ which I've to use in Java. I've the complete knowledge of the public methods in the dll. Now to use these I'm kind of using a wrapper C++ program, which creates the object and calls the functions in the dll when required. And I interface this C++ code with the Java using JNI. Is there any other efficient way of doing this. That is to create objects of a class and use its functions directly using JNI or any other library in Java 开发者_开发百科


In order to call native(C/C++) code from Java, You will have to do Marshalling of the objects between native world and Java, JNI justs does that and your approach just looks right to me.


Direct use of C++ classes in java is only possible with CNI, which means you have to use gcj (gnu compiler for java). Otherwise you have to write a jni wrapper class yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜