import java.util.*;
import javax.comm.*;
public class ComTest {
static Enumeration en = CommPortIdentifier.getPortIdentifiers();
static CommPortIdentifier portId;
public static void main(String[] args) {
while(en.hasMoreElements()){
portId = (CommPortIdentifier)en.nextElement();
if(portId.getPortType() == CommPortIdentifier.PORT_SERIAL){
System.out.println(portId.getName());
}
}
}
}
en.hasMoreElements()总是返回false,请问这是怎么回事情的哈?
import javax.comm.*;
public class ComTest {
static Enumeration en = CommPortIdentifier.getPortIdentifiers();
static CommPortIdentifier portId;
public static void main(String[] args) {
while(en.hasMoreElements()){
portId = (CommPortIdentifier)en.nextElement();
if(portId.getPortType() == CommPortIdentifier.PORT_SERIAL){
System.out.println(portId.getName());
}
}
}
}
en.hasMoreElements()总是返回false,请问这是怎么回事情的哈?
你到我的电脑 ---硬件 ---设备管理器 里看看你有串口吗?就知道是什么问题
另外javax.comm.properties 放到java_home\jre\lib目录中
http://www.programmerstudy.com/programme/java/20084/97.html