Hi,
I am trying to write an application to read from the COM port on my PC using the java communications api. However, when I try to enumerate the ports on my Windows 2000 PC it doesn't return any ports.. Here is my Code:
import javax.comm.*;
import java.util.*;
public class PortList {
public static void main(String [] args){
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while(portList.hasMoreElements()) {
CommPortIdentifier portId = (CommPortIdentifier)portList.nextElement();
if( portId.getPortType() ==
CommPortIdentifier.PORT_SERIAL)
{
System.out.println("Serial port: " +
portId.getName());
} else if (portId.getPortType() ==
CommPortIdentifier.PORT_PARALLEL)
{
System.out.println("Parallel port: " +
portId.getName());
} else
System.out.println("Other port: " +
portId.getName());
}
}
}
What am I doing wrong??
Neil
I am trying to write an application to read from the COM port on my PC using the java communications api. However, when I try to enumerate the ports on my Windows 2000 PC it doesn't return any ports.. Here is my Code:
import javax.comm.*;
import java.util.*;
public class PortList {
public static void main(String [] args){
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while(portList.hasMoreElements()) {
CommPortIdentifier portId = (CommPortIdentifier)portList.nextElement();
if( portId.getPortType() ==
CommPortIdentifier.PORT_SERIAL)
{
System.out.println("Serial port: " +
portId.getName());
} else if (portId.getPortType() ==
CommPortIdentifier.PORT_PARALLEL)
{
System.out.println("Parallel port: " +
portId.getName());
} else
System.out.println("Other port: " +
portId.getName());
}
}
}
What am I doing wrong??
Neil