在网上查了查,都说目前RXTX很值得一学,故而从零开始,一点点累计。
首先,找到RXTX主页:http://rxtx.qbang.org/wiki/index.php/Download。下载需要准备的资源。
在Pre-Built Binaries中,可以找到源码以及动态库的下载地址,如下图,可以根据实际需要选择下载。并且在接下来的文档中还有很详细的使用说明,包括如何提取文件、安装等等。
但在x64 Binaries对64位的pc机支持中,专门有了特殊的说明,鉴于本机使用的win10_pro 64,故而之前的下载暂时还未下载学习,便先从此处开始了,其对应地址为http://fizzed.com/oss/rxtx-for-java,可以点击连接找到下载资源,此处我选择了mfz-rxtx-2.2-20081207-win-x64.zip下载。
在rxtx主页中,可以找到对应系统的安装方法:
- Installation on MacOS X
- Installation on Linux
- Installation on BSD
- Installation on MS-Windows
- Installation on Toybox
不过按照文档的描述,按照标准的安装流程,在安装之后总会有问题,后来在文档中发现了一个更加可靠的描述http://rxtx.qbang.org/wiki/index.php/Using_RXTX_In_Eclipse,
作者是这么描述的:
This is how I add and use RXTX in Eclipse for Win32 Projects, there are probably other ways but it works for me. [1]
- Copy RXTXcomm.jar, rxtxSerial.dll and rxtxParallel.dll files to the lib directory of your project
- Under Project | Properties | Java Build Path | Libraries
- click Add JARs... Button
- Select the RXTXComm.jar from lib directory
- Jar should now be in the Build Path
- expand the RXTXComm.jar entry in the list and select "Native Library Location"
- Select the project lib directory and apply
Be careful when using System.in.read() and rxtx in win32; It can trip across a known JRE deadlock bug
Alternative way:
The above setup didn't quite work for me, so here is an alternative.
- Copy RXTXcomm.jar to the lib directory of your project
- Navigate your package explorer to the lib folder, right click on RXTXcomm.jar | Build Path | Add to built path
- Copy rxtxSerial.dll and rxtxParallel.dll files to the root directory of your project
- Under Run | Run configurations | Classpath tab | User entries | Advanced | Add folder, choose the root folder of your project
- This should be enough just to run it under Eclipse, when deploying a runnable jar, just make sure the dlls are on the same folder as the jar (JVM assumes it for classpath)
1、拷贝RXTXcomm.jar到工程库目录下;
2、将RXTXcomm.jar加到工程构建路径中;
3、将rxtxSerial.dll和两个库文件拷贝到工程根目录下;
转载地址: