I am trying to develop a application in java (Swing) in which I have to get and store that event coming from device in database. I used RXTX to find all port which is in use but I want only that port in which my device is connected . I used a prolific driver.
private void findPorts() {
Enumeration<CommPortIdentifier> portEnum =
CommPortIdentifier.getPortIdentifiers();
int portCount = 0;
while ( portEnum.hasMoreElements() ) {
portIdentifier = portEnum.nextElement();
// populate the portNames array for display in gui.jcbPort
//if the port is a serial port
if(portCount < portNames.length &&
portIdentifier.getPortType() == portIdentifier.PORT_SERIAL)
{
//put it in the array
portNames[portCount] = portIdentifier.getName();
portCount++;
}
}
}