在代码中: CommPortIdentifier.getPortIdentifier(portname) 无法识别 ComPort。
{CommPortIdentifier cpi = null;
try {
cpi = CommPortIdentifier.getPortIdentifier(portname);
if (cpi.isCurrentlyOwned()) {
System.out.println("Error: Port is currently in use");
}
com = (SerialPort) cpi.open("COM", 10);
com.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
} catch (Exception e1) {
e1.printStackTrace();
return false;
}}
我已经尝试了链接how-to-install-java-communications中的解决方案, 但失败了,请帮助我。