We help IT Professionals succeed at work.

why would CommPortIdentifier.getPortIdentifier() get a NoSuchPortException?

AlanNShapiro
AlanNShapiro asked
on
When i execute the line of code:
CommPortIdentifier portId1 = CommPortIdentifier.getPortIdentifier("COM4");

I get a NoSuchPortException.

I know that i have a modem attached on COM4.

What can possibly explain this problem? Does it have something to do with a property file, that getPortIdentifier() is looking in? Does it have to do with a driver that is not finding the port?

Thanks.
Alan Shapiro


 

 

 

 

 

 
 
Comment
Watch Question

As you are probably aware, the API states that a NoSuchPortException is "thrown when a driver can't find the specified port".  Thus, to solve this you must move out of the realm of Java.  My first approach would be:

1) Double check that the system does indeed have a port identified as COM4 (assume case-sensitivity).
2) Check that you have the correct implementation of the Java communication API. If not download a correct one, otherwise try an alternative implementation.

Good luck.

Author

Commented:
It works when i use the javax.comm from Java 1.1.8. I don't know why it doesn't work with the javax.com from Java 1.6. From what i have read, little has changed since this older version of javax.comm, so i will use that version for now.
Glad to hear it's working, although I imagine using an older version causes a little uneasiness.

Regards.