Java RXTX and packaging

谁说胖子不能爱 提交于 2019-12-13 18:09:08

问题


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.

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?

Thank you.


回答1:


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.

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.)



来源:https://stackoverflow.com/questions/14596406/java-rxtx-and-packaging

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