title: serial port identification with java on ubuntu
body: <p>I'm trying to connect a serial application on ubuntu with Java<br>
  After searching and reading resources,I add comm.jar and RXTXcomm.jar in the library.<br>
  I use the following code to identify the comports. In my system there are three ports but it is showing false in <code>ports.hasMoreElements()</code> method.<br>
  Kindly look into the code and help me.  </p>
  
  <pre><code>String wantedPortName = "/dev/ttya";
  ///dev/ttyS0 و /dev/ttyS1 نیز تست شد
  Enumeration portIdentifiers = CommPortIdentifier.getPortIdentifiers();
  CommPortIdentifier portId = null;  // will be set if port found
  while (portIdentifiers.hasMoreElements())
  {
      CommPortIdentifier pid = (CommPortIdentifier) portIdentifiers.nextElement();
      if(pid.getPortType() == CommPortIdentifier.PORT_SERIAL &amp;&amp;
        pid.getName().equals(wantedPortName)) 
    {
      portId = pid;
      break;
    }
  }
  if(portId == null)
  {
       System.err.println("Could not find serial port " + wantedPortName);
       System.exit(1);
  }    
  </code></pre>