简体   繁体   English

java7中DLL的调用方法

[英]call method from DLL in java7

From what I understood dll are not standardized. 从我了解的dll是不规范的。 thus one cannot just call something in a dll. 因此,不能只在dll中调用某些内容。 However I found this : http://johannburkard.de/software/nativecall/ 但是我发现了这个: http : //johannburkard.de/software/nativecall/

This library allow you to call any method from a dll in java, so it seems that you can call any method in a dll. 该库允许您从java中的dll调用任何方法,因此您似乎可以在dll中调用任何方法。 but it was done for 32 bit system, thus I cannot use it. 但是它是针对32位系统完成的,因此我无法使用它。

I have this dll, autohotkey.dll, I know there is the method "ahkExec" inside which take a String as parameter. 我有这个DLL,autohotkey.dll,我知道里面有一个方法“ ahkExec”,它以String作为参数。

Is this really not possible to run it from java without using some kind of c++ magic? 如果不使用某种C ++魔术,这真的不可能从Java运行吗?

Thanks. 谢谢。

ps : here is how it is done with nativeCall : https://gist.github.com/brigand/1526712 ps:这是使用nativeCall的方法: https ://gist.github.com/brigand/1526712

从1.0版开始,您就可以使用Java本机接口(JNI)来用Java调用DLL。

There is no magic in invoking external methods but you have to follow some rules based on what JNI provides . 调用外部方法没有魔术,但是您必须根据JNI提供的内容遵循一些规则。

If you need to use one function from library you could write a specific Wrapper-class like in this tutorial 如果您需要使用库中的一个函数,则可以像本教程中一样编写一个特定的Wrapper类

For more tricky things better to work with SWIG 有关更棘手的事情,最好与SWIG一起使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM