I'm running a small program that should list all of the comm ports that are available on the computer. The only problem is that nothing is recognized. I've stepped through the program and it jumps over the while .....hasMoreItems. When I set the hasMoreItems to false it executes it. There are no syntax errors and it runs completely, it just doesn't give me the info I need.
Thanks in advance!
-
package gps;
-
-
import javax.comm.*;
-
import java.util.Enumeration;
-
public class Main {
-
-
public static void main(String[] args) {
-
Enumeration port = CommPortIdentifier.getPortIdentifiers();
-
while (port.hasMoreElements()) {
-
CommPortIdentifier ports = (CommPortIdentifier) port.nextElement();
-
String type="";
-
switch (ports.getPortType()) {
-
case CommPortIdentifier.PORT_PARALLEL:
-
type = "Parallel";
-
break;
-
case CommPortIdentifier.PORT_SERIAL:
-
type = "Serial";
-
break;
-
default: /// Shouldn't happen
-
type = "Unknown";
-
break;
-
}
-
System.out.println(ports.getName() + ": " + type);
-
}
-
}
-
}
-