gnu.io.PortInUseException: Unknown Application?

Ramesh Kotha picture Ramesh Kotha · Jan 28, 2012 · Viewed 20.3k times · Source
void connect ( String portName ) throws Exception
{
    CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
    if ( portIdentifier.isCurrentlyOwned() )
    {
        System.out.println("Error: Port is currently in use");
    }
    else
    {
        System.out.println(portIdentifier.getCurrentOwner());
        CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);

        if ( commPort instanceof SerialPort )
        {
            SerialPort serialPort = (SerialPort) commPort;
            serialPort.setSerialPortParams(115200,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);

            InputStream in = serialPort.getInputStream();
            OutputStream out = serialPort.getOutputStream();

            (new Thread(new SerialReader(in))).start();
            (new Thread(new SerialWriter(out))).start();

        }
        else
        {
            System.out.println("Error: Only serial ports are handled by this example.");
        }
    }     
}

is giving

gnu.io.PortInUseException: Unknown Application
    at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)

i am using RXTX with Java in windows 7 home 64-bit.

Answer

bmalets picture bmalets · Dec 24, 2013

Check that /var/lock folder exist on your machine.


mkdir /var/lock
chmod go+rwx /var/lock