我怎样才能使用java中的DLL定义的东西 [英] How can I use something defined in DLL from java

查看:57
本文介绍了我怎样才能使用java中的DLL定义的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我目前正在做一个项目,我们需要调用名为 Skype4COM [ ^ ]只提供界面。我们必须将这个中间件与我们的java程序结合起来,以实现我们的目标。我搜索了这个主题,但没有找到任何有用的东西。从Internet收集的这些信息都是关于如何首先通过java创建DLL然后在C / C ++中实现它,但我认为Skype4COM已经实现了相关的接口,我们可以直接使用这些接口做其他事情而无需通过重新实现我们自己。



这是一个接口的例子:

 HRESULT CreateChatUsingBlob([in] BSTR Blob,[ out,retval] IChat ** pChat); 



用于使用给定blob返回现有或加入新聊天。



不幸的是,我不知道如何获取函数的输出以及如何使用java中定义的这个类,java和java的类型之间的对应关系(就像指针类型一样)也困扰着我。



有人能给我一些建议吗?如果你能给我一些确切的例子,我们非常感激。



非常感谢。

解决方案

您需要使用JNI( Java Native Interface )框架。请参阅:

http://en.wikipedia.org/wiki/JNI [< a href =http://en.wikipedia.org/wiki/JNItarget =_ blanktitle =New Window> ^ ],

http://docs.oracle.com/javase/7/docs/technotes/guides/jni/index .html [ ^ ],

http:// electrofriends。 com / articles / jni / jni-part1-java-native-interface / [ ^ ],

JNI Basics - 1 [ ^ ]。



-S A

Hi All,
I am doing a project currently, we need to call third-party library in DLL format named Skype4COM [^] which only gives the interface. we have to combine this middleware with our java program to reach our goal. I searched for this topic so much but not found anything useful. This information collected from Internet is all about how the create DLL through java first and then implement it in C/C++, but I think the Skype4COM has implement the related interface and we can use these interface directly to do other things without re-implementing by ourselves.

Here is a example of the interfaces:

HRESULT  CreateChatUsingBlob ([in] BSTR Blob,[out, retval] IChat **pChat);


which is uesed to "Returns existing or joins a new chat using given blob."

Unfortunately, I don''t know how to get the function''s output and how to use the classes defined in this DLL from java, the corresponding relationship between the types of java and the DLL (like the pointers type) also haunts me.

Can anyone give me some suggestion? It''s very appreciate that if you can give me some exactly examples.

Thanks a lot.

解决方案

You need to use the JNI (Java Native Interface) framework. Please see:
http://en.wikipedia.org/wiki/JNI[^],
http://docs.oracle.com/javase/7/docs/technotes/guides/jni/index.html[^],
http://electrofriends.com/articles/jni/jni-part1-java-native-interface/[^],
JNI Basics - 1[^].

—SA


这篇关于我怎样才能使用java中的DLL定义的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆