[英]CommPortIdentifier.getPortIdentifier(portname) throughing exception
In the code: CommPortIdentifier.getPortIdentifier(portname) is not able to indentify the ComPort. 在代码中: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;
}}
I have tried the solution in the link how-to-install-java-communications but failed, please help me regarding. 我已经在链接how-to-install-java-communication中尝试了该解决方案,但是失败了,请帮助我。
The solution provided in the https://edn.embarcadero.com/article/31915 works. https://edn.embarcadero.com/article/31915中提供的解决方案有效。 In my case, I was using both 32 bit JRE and 64 bit JRE on my PC.
就我而言,我在PC上同时使用了32位JRE和64位JRE。 I placed the required files according to my java home and used different JRE.
我根据我的java主页放置了所需的文件,并使用了不同的JRE。
To download comm.jar, win32com.dll and property file I have used http://kishor15389.blogspot.de/2011/05/how-to-install-java-communications.html 要下载comm.jar,win32com.dll和属性文件,我使用了http://kishor15389.blogspot.de/2011/05/how-to-install-java-communications.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.