Shantanu Banerjee
Shantanu Banerjee

Reputation: 1447

getting a javax.comm.NoSuchPortException when the port exist

Hello I have seen this Why am I getting a Java NoSuchPortException when the port exists? post but It's not very clear to me!!

In device manager it shows COM3 is exist and I can connect it through putty, but this piece of code is getting this error/exception.

try {
       portId = CommPortIdentifier.getPortIdentifier("COM3");
    } catch (NoSuchPortException ex) {
       System.out.println(ex);
    }

try {
     serialPort = (SerialPort)portId.open("S2CFrameWork", 5000);
    } catch (PortInUseException e) {
        System.out.println(e);
    }

this simple code thrown a javax.comm.NoSuchPortException, I have also tried this with using Enumeration to get the list of avilable port but still it shows exception. Can anyone solve this issue?

Upvotes: 2

Views: 14556

Answers (1)

Shantanu Banerjee
Shantanu Banerjee

Reputation: 1447

comm.jar should be placed in:

%JAVA_HOME%/lib

%JAVA_HOME%/jre/lib/ext

win32com.dll should be placed in:

%JAVA_HOME%/bin

%JAVA_HOME%/jre/bin

%windir%System32

javax.comm.properties should be placed in:

%JAVA_HOME%/lib

%JAVA_HOME%/jre/lib

Upvotes: 6

Related Questions