Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Comm api 2.0 - CommPortIdentifier.getPortIdentifiers() returns empty enum



Hi,
I'm trying to open connetion with my GSM modem which it connected to my PC by RS-232 cable.
I'm trying to run my program on Windows XP.
But, when i'm running the following piece of code, the enumeration return empty.
How it can be solved?

Enumeration en = CommPortIdentifier.getPortIdentifiers();
System.out.println(en);

// Iterate through the ports.
while (en.hasMoreElements()) {
    portId = (CommPortIdentifier) en.nextElement();
    if(portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
         System.out.println(portId.getName());
    }
}

On the Widows, Device manager, i can find the modem under Ports section/
Thanks,
Eyal.