title: Opening Serial Port with PureJavaComm leads to PortInUseException
body: <p>for reading a GPS signal from COM3, I'm trying to connect to the port via Java using PureJavaComm (<a href="http://www.sparetimelabs.com/purejavacomm/purejavacomm.php" rel="nofollow">http://www.sparetimelabs.com/purejavacomm/purejavacomm.php</a>)</p>
  
  <p>Using the code below all of the systems COM ports are found and listed:</p>
  
  <pre><code>    List&lt;String&gt; list = new ArrayList&lt;String&gt;();
  
      Enumeration portList = CommPortIdentifier.getPortIdentifiers();
      while (portList.hasMoreElements()) {
          CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
          if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
              list.add(portId.getName());
          }
      }
      System.out.println("Ports: " + list.toString());
  </code></pre>
  
  <p>Nevertheless, if I'm trying to connect to one port by using the below code I'm getting a PortInUseException. The weird thing is, the exception appears by using the code on all com ports, even the ones which are simulated. </p>
  
  <pre><code>    try {
          portId = CommPortIdentifier.getPortIdentifier("COM3");
      } catch (NoSuchPortException e1) {
          e1.printStackTrace();
      }
  
      SerialPort serialPort = null;
      try {
           serialPort = (SerialPort) portId.open("GpsApp", 2000);
           serialPort.close();
      } catch (PortInUseException e) {
          log.error(e);
      }
  </code></pre>
  
  <p><code>portId.currentOwner()</code> returns <code>null</code> and <code>portId.isCurrentlyOwned</code> returns <code>false</code>. On the other side, connecting to the same port by using putty works just fine.</p>
  
  <p>Do you have any ideas? I'm using a Win7 x64 OS and 64Bit Java 1.7, the deployment server is a JBoss 7.2.0</p>
  
  <p>I already tried to disable the COM Port I want to connect to, restart and enable it again. Unfortunately, it didn't help.</p>