private void initialize() throws PortInUseException, UnsupportedCommOperationException, IOException, PortNotFoundException {
        String testPort = System.getProperty("xwot.test.port");
        logger.debug(testPort);
        if(testPort != null && !testPort.equals("")) {
            PORT_NAMES = new String[1];
            PORT_NAMES[0] = testPort;
        }
        CommPortIdentifier portId = null;
        Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
        logger.debug("looking for ports...");
        if (portEnum.hasMoreElements()) {
            logger.debug("serial port(s) found on your os");
        } else {
            logger.error("No port found. Linux user: don't forget that only ports like this: /dev/ttyS* will be scanned");
        }
        //First, Find an instance of serial port as set in PORT_NAMES.
        while (portEnum.hasMoreElements()) {
            CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
            for (String portName : PORT_NAMES) {
                logger.debug(portName + " == " + currPortId.getName());
                if (currPortId.getName().equals(portName)) {
                    portId = currPortId;
                    break;
                }
            }
        }
        if (portId == null) {
            logger.error("Could not find COM port.");
            close();
            throw new PortNotFoundException();
        }

        // open serial port, and use class name for the appName.
        serialPort = (SerialPort) portId.open(this.getClass().getName(),
                TIME_OUT);

        // set port parameters
        serialPort.setSerialPortParams(DATA_RATE,
                SerialPort.DATABITS_8,
                SerialPort.STOPBITS_1,
                SerialPort.PARITY_NONE);

        // open the streams
        input = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));
        output = serialPort.getOutputStream();
        try {
            addNewDataListener();
        } catch (TooManyListenersException ex) {
            Logger.getLogger(RxtxConnection.class.getName()).log(Level.SEVERE, null, ex);
        }

    }