日期:2014-05-17  浏览次数:20772 次

JAVA开发web项目中的串口程序问题????
Enumeration portList=CommPortIdentifier.getPortIdentifiers();
System.out.println(portList.hasMoreElements()+"........"); //为false 下面就不执行了
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals("COM1")) break;
}
}

我将串口的三个包在jdk、jre下面都放的有,查了很多资料只在main方法中可运行,在项目中运行就CommPortIdentifier.getPortIdentifiers();返回false!
我用的SSH框架,异步提交更新数据时,调用这个串口程序!!!!

------解决方案--------------------
代码已贴,接分