Java RXTX和包装 [英] Java RXTX and packaging

查看:212
本文介绍了Java RXTX和包装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个内置netbeans的java程序,它使用来自这里。到目前为止,它在Windows和Linux中都运行良好。

I have a java program that built in netbeans that uses the RXTX from Here. So far it works very well in both windows and linux.

我的问题:是否可以在JAR中包含所需的RXTX文件而无需按照上的说明安装它们RXTX网站。我希望能够将所有包含文件的JAR交给Linux或Windows上的人,并让它正常工作。

My question: Is it possible to include the needed RXTX files in the JAR without installing them as per the instruction on the RXTX site. I would like to be able to just give the JAR to people on Linux or Windows with all included files and have it just work.

这是可能的,什么是最好的这样做的方法?

Is that possible and what is the best way to do that?

谢谢。

推荐答案

你不要不需要安装它们 - 您需要做的就是将 java.library.path VM参数指向包含该文件的文件夹适当的DLL文件。

You don't need to install them per-se - all you need to do is point the java.library.path VM argument at a folder containing the appropriate DLL files.

然而,对于Jar文件,这将涉及在某处提取它们然后在初始化RXTX之前单独加载DLL,因为它们无法读取和直接从Jar文件中使用(因为它本质上是一个zip存档。)这个问题应该指向正确的方向(不要忘记没有什么能阻止你将它们提取到临时位置并调用 deleteOnExit()在文件上,所以它不会比它必须长寿。)

However, for a Jar file this will involve extracting them somewhere and then loading the DLLs separately before you initialise RXTX, since they can't be read and used from inside the Jar file directly (since it's essentially a zip archive.) The top answer on this question should point you in the right direction here (don't forget there's nothing stopping you extracting them to a temporary location and calling deleteOnExit() on the file so it's not around longe than it has to be.)

这篇关于Java RXTX和包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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