最近在做java监听串口一开始根本没有头绪,总是会报以下的错误:
Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library.path
Caught java.lang.UnsatisfiedLinkError: com.sun.comm.SolarisDriver.readRegistrySerial(Ljava/util/Vector;Ljava/lang/String I while loading driver com.sun.comm.SolarisDriver
Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library.path
Caught java.lang.UnsatisfiedLinkError: com.sun.comm.SolarisDriver.readRegistrySerial(Ljava/util/Vector;Ljava/lang/String I while loading driver com.sun.comm.SolarisDriverVerifying Comm Build Environment
查了好久
最后还是看了api才知道是配置出错了...(本人完全新手...)
API中有如下几句话:
1.Windows: place the
win32com.dll in <jdk>\jre\bin directory.
Solaris: put the
libSolarisSerialParallel.so in the LD_LIBRARY_PATH.(本人用的是window xp的,这个就...)
2.Place the
comm.jar in <jdk>\jre\lib\ext.
3.Place the
javax.comm.properties in <jdk>\jre\lib .
根据这个提示修改了配置后测试通过~
所用测试类代码如下:
PortTest.java
import javax.comm.*;
import java.util.*;
public class PortTest {
public static void main(String[] args) {
String port_name;
for (int i = 1; i < 100; i++) {
port_name = "COM" + i;
try {
CommPortIdentifier port_id = CommPortIdentifier
.getPortIdentifier(port_name);
System.out.println("Port " + port_name + " exists");
} catch (NoSuchPortException e) {
System.out.println("No port " + port_name);
}
} // for
} // main
}
---------------------------------------------
控制台输出:
Port COM1 exists
Port COM2 exists
Port COM3 exists
Port COM4 exists
No port COM5
...
先记下了~
其中会用到的文件都在附件中,有需要的话请自行下载~
备注:附件给的是JDK1.2版本的,但我开发用的是JDK1.6版本,测试通过了
分享到:
相关推荐
里面有windows(x64和x86)和linux(x64和x86)的驱动包。请将rxtx解压包中的 rxtxParallel.dll,rxtxSerial.dll 这两个文件复制到到X:\jre\lib目录下面,RXTXcomm.jar配置到项目中
1.1 常见的Java串口包... 1 1.2 串口包的安装(Windows下)... 1 2 串口API概览... 2 2.1 javax.comm.CommPort2 2.2 javax.comm.CommPortIdentifier3 2.3 javax.comm.SerialPort3 2.4 串口API实例... 3 2.4.1...
Java串口通信详解收藏1 串口通信简介... 1 1.1 常见的Java串口包... 1 1.2 串口包的安装(Windows下)... 1 2 串口API概览... 2 2.1 javax.comm.CommPort2 2.2 javax.comm.CommPortIdentifier3 2.3 javax.comm...
使用RXTX包进行串口读写,有完整用户界面,可以定义参数后监听串口或者向串口发送数据。请参考网上RXTX的配制方法配置好Eclipse以后运行,如不配置无法正常编译。
Java绘制图片火焰效果,源代码相关注释:前景和背景Image对象、Applet和绘制火焰的效果的Image对象、Applet和绘制火焰的效果的Graphics对象、火焰效果的线程、Applet的高度,图片到图片装载器、绘制火焰效果的X坐标...
Java绘制图片火焰效果,源代码相关注释:前景和背景Image对象、Applet和绘制火焰的效果的Image对象、Applet和绘制火焰的效果的Graphics对象、火焰效果的线程、Applet的高度,图片到图片装载器、绘制火焰效果的X坐标...
其它相关接口的说明 561 HTTP协议基本概念及其特点 563 获取Cookie 565 HTTP响应报头--Response 566 会话管理 566 Servlet过滤器 569 Servlet监听器 576 内容总结 579 独立实践 580 第二十九章: Jsp 技术 583 学习...
§2.4.1.6 理解监听日志中信息 50 §2.4.1.7 理解连接管理器信息 53 §2.4.2 跟踪文件( Trace File ) 53 §2.4.2.1 跟踪文件的命名: 54 §2.4.2.2 参数设置与初始化文件: 54 §2.4.2.3 在控制实用程序运行中设置...