serialPort = (SerialPort) portId.open("SimpleReadApp", 2000) opens COM1 serial port identified in the following code segment while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals("COM1")) { System.out.println("The port is: " + portId.getName()); RFIDTagRead reader = new RFIDTagRead(); } } }
Example 1: Opening COM1.