簡體   English   中英

CommPortIdentifier.getPortIdentifier(portname)通過異常

[英]CommPortIdentifier.getPortIdentifier(portname) throughing exception

在代碼中: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-communication中嘗試了該解決方案,但是失敗了,請幫助我。

https://edn.embarcadero.com/article/31915中提供的解決方案有效。 就我而言,我在PC上同時使用了32位JRE和64位JRE。 我根據我的java主頁放置了所需的文件,並使用了不同的JRE。

要下載comm.jar,win32com.dll和屬性文件,我使用了http://kishor15389.blogspot.de/2011/05/how-to-install-java-communications.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM