动态加载Java小程序内的本地库 [英] Dynamically loading a native library inside Java applet

查看:196
本文介绍了动态加载Java小程序内的本地库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个Java小程序会从用户的串口读取。为此,我现在用的是的Java通信API 与的 RXTX库。我已经成功地设法通读本地Java应用程序的数据,但我似乎无法从applet中做同样的。问题是,RXTX库是一个机库,我还没有找到一种方法来加载Java小程序里面这个库。我已经发现了两个有趣的文章(使用 JNI的小程序其中的这篇文章),但两者都超过10岁了,我想知道如果有一个新的解决方案。或者,如果你能提出替代方案,我很想听到了!

I am trying to write a Java applet that will read from a user's serial port. For this I am using the Java Comm API in conjuction with the RXTX library. I've successfully managed to read data through a local Java application but I can't seem to do the same from within an applet. The problem is that the RXTX library is a native library and I haven't found a way to load this library inside the Java applet. I've found two interesting articles (Using JNI in Applets which references to this article), but both are over 10 years old and I am wondering if there is a newer solution. Or if you can suggest an alternative, I would love to hear it!

推荐答案

使用Java Web Start的。您可以包括本地库作为一个签发的jar,一切都应该工作。

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

1)把本地图书馆的一个罐子在根目录
2)签署所有的罐子
3)写一个JNLP引用的所有jar文件(去做关于如何编写一个搜索JNLP的)

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)

之后,它应该工作

这篇关于动态加载Java小程序内的本地库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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