Dynamically loading a native library inside Java applet

馋奶兔 提交于 2019-11-29 05:20:18

Use Java Web Start. You can include the native library as a signed jar and everything should work.

1) put the native librarys in a jar in the ROOT directory 2) sign ALL the jars 3) write a JNLP referencing all the jars (go do a search on how to write jnlp's)

after that it should work

Firstly I'd suggest doing that in an Applet is probably a bad idea.

If you do go ahead anyway, JNLPAppletLauncher may help.

I don't know about applets, other than they're locked down heavily wrt. security/accessing the machine's resources etc.

If you need a web-deployable solution, have you looked at Java Web Start ? See in particular this FAQ entry

Frankly, trying to access devices from a Java applet is a bad idea even if you could make it work, and loading a dynamic library into the conventional applet is an even worse idea; in fact, I'd be astounded if you could find a way to trick a modern browser into doing it. (Consider the possible security implications.)

You're better off, as suggested on other questions, building an app that can be launched with Web Start.

I'd be real interested in the answer here also. My suggestion would be to install the .jar and .dll for RXTX into the \program files\java\ tree. You could install them on the target system before trying to use the applet. I like the idea of using Java Web Start. If you sign the applet, can't you read/write any file on the machine? So you could install the .jar and .dll and then use them afterward?

For windows, I suggest using "Windows Java Serial Com Port Driver" rather than rxtx. You can download it from http://www.engidea.com/blog/informatica/winjcom/winjcom.html I've found it much easier to install and use and much more bug-free. I was unable to use RXTX with USB serial devices because RXTX would crash when the USB port was unplugged. winjcom solved these problems for me, and more.

I'm still trying to decide how to deploy the DLL, but I'm not sweating it because I don't expect the DLL for "Windows Java Serial Com Port Driver" to change. -Stosh

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