Load .DLL with applet and use it on client

廉价感情. 提交于 2019-11-27 22:50:47

问题


Can I load .dll from server to client within applet, and then call methods of loaded .dll (using JNI) on client side?


回答1:


Certainly. The applet will need to be digitally signed by the developer, and trusted by the end user (they click 'OK' when prompted). Put the natives in the root of a Jar and add it to the run-time class-path of the applet, using a reference in the archive attribute.

Using the traditional method of deploying natives to an applet using the archive attribute has the disadvantage that every client gets the natives for Windows, OS X and *nix. 3 times as many natives as they actually need.

A recent (Java Plug-In 2, introduced in Sun's version 1.6.0_10) ability is to launch embedded applets using Java Web Start, which then allows us to partition the download of natives for the user. Each OS will get only the natives it needs.


..how to declare applet class-path?

It is specified in the resources section.

E.G. from docs.

<resources os="SunOS" arch="sparc">
  <nativelib href="lib/solaris/corelibs.jar"/>
</resources>

Any resources section with no os or arch attribute will be downloaded by all JWS clients, the rest only by those that match.



来源:https://stackoverflow.com/questions/12154013/load-dll-with-applet-and-use-it-on-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!