import gnu.io.CommPortIdentifier; import java.util.Enumeration; public class Test { public static void main(String[] args) { System.out.println("main method start."); try { Enumeration portList = CommPortIdentifier.getPortIdentifiers(); CommPortIdentifier port = null; while (portList.hasMoreElements()) { port = (CommPortIdentifier)portList.nextElement(); System.out.println(port.getName()); } } catch(Exception e) { e.printStackTrace(); } } }