简体   繁体   English

如何从JSNI调用Dll方法在GWT Web应用程序中使用?

[英]How to call Dll method from JSNI to use in GWT web application?

I have a GWT web application. 我有一个GWT Web应用程序。

It calls method from another class(using JSNI method). 它从另一个类调用方法(使用JSNI方法)。

But I want to Call a dll method from that class...How can i do that? 但是我想从那个类中调用一个dll方法......我怎么能这样做?

public class external_class {
public native void shows()/*-{window.alert("hello");}-*/;
}

in GWT web application calling like 在GWT Web应用程序中调用

external_class obj = new external_class();
            obj.shows();

how can I invoke shows() method if I defined it in a dll file? 如果我在dll文件中定义它,如何调用shows()方法? or how can i directly call a dll method from GWT application through JSNI? 或者如何通过JSNI从GWT应用程序直接调用dll方法?

please give me a solution.... 请给我一个解决方案....

You can not call a DLLs in GWT. 你不能在GWT中调用DLL。 GWT compiles Java code to Javascript code which runs inside a webbrowser. GWT将Java代码编译为在Web浏览器内运行的Javascript代码。 Javascript can not call DLLs directly, if you want to do something with a DLL I suggest you take a look into browser plugins. Javascript不能直接调用DLL,如果你想用DLL做一些事我建议你看一下浏览器插件。

In browser plugins you can include your dll (only windows) and have your javascript call that plugin. 在浏览器插件中,您可以包含您的DLL(仅限Windows)并让您的javascript调用该插件。

To me it looks like you need to use an Applet and jnlp to load the native libraries in. From there you can communicate between GWT and the applet using the JSObject or a library like GWT-AI (personally I just code this by hand, I have only used GWT-AI a few times). 对我而言,你需要使用Applet和jnlp来加载本机库。从那里你可以使用JSObject或像GWT-AI这样的库在GWT和applet之间进行通信(我个人只需手动编写代码,我只使用了GWT-AI几次)。 I believe for the applet side you could use JNA for your bindings. 我相信applet方面你可以使用JNA进行绑定。

If this doesn't make sense, or sounds a bit like gibberish, you may need to enlist help, a lot can go wrong bringing between java and native libraries, and you may need more specialized help to actually make progress on this, it's tricky. 如果这没有意义,或听起来有点像胡言乱语,你可能需要寻求帮助,在java和本地库之间带来很多可能会出错,你可能需要更专业的帮助才能在这方面取得进展,这很棘手。

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

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