在 Java 小程序中动态加载本机库 [英] Dynamically loading a native library inside Java applet

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

问题描述

我正在尝试编写一个 Java 小程序,它将从用户的串行端口读取.为此,我将 Java Comm APIRXTX 库.我已经成功地设法通过本地 Java 应用程序读取数据,但我似乎无法从小程序中读取数据.问题是 RXTX 库是本机库,我还没有找到在 Java 小程序中加载这个库的方法.我发现了两篇有趣的文章(Using JNI in Applets,其中引用了 这篇文章),但我和他们都超过 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) 将本地库放在 ROOT 目录下的 jar 中2)在所有罐子上签名3) 编写一个引用所有 jars 的 JNLP(去搜索如何编写 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天全站免登陆