ComExeption

port = (SerialPort) c.open("Terminal", 8000);

System.out.println(c.getCurrentOwner());

is = port.getInputStream();

os = port.getOutputStream();

port.addEventListener(this);

port.notifyOnDataAvailable(true);

try {

port.setSerialPortParams(9600,

SerialPort.DATABITS_8,

SerialPort.STOPBITS_1,

SerialPort.PARITY_NONE);

} catch (UnsupportedCommOperationException e) {}

Thread thread = new Thread(this);

thread.start();

}

catch (PortInUseException e) {

System.out.print(e.currentOwner);

}

catch (IOException e) {

}

catch (TooManyListenersException e) {}

}

public void run() {

try {

Thread.sleep(20000);

} catch (InterruptedException e) {}

}

public void serialEvent(SerialPortEvent arg0) {

switch(arg0.getEventType()){

case SerialPortEvent.BI:

case SerialPortEvent.OE:

case SerialPortEvent.FE:

case SerialPortEvent.PE:

case SerialPortEvent.CD:

case SerialPortEvent.CTS:

case SerialPortEvent.DSR:

case SerialPortEvent.RI:

break;

case SerialPortEvent.OUTPUT_BUFFER_EMPTY:

case SerialPortEvent.DATA_AVAILABLE:

int c;

StringBuffer strb = new StringBuffer();

try {

while (is.available() > 0) {

c=is.read();

strb.append((char)c);

}//End of While loop

//inputStream.close();

} catch (IOException e) {}

}

but i have an exption: javax.comm.PortInUseException: Port currently owned by Unknown Windows Application

how can i solve sthis problem?

[1642 byte] By [Nushasilaa] at [2007-11-26 19:57:17]
# 1
Please stick with the original thread. http://forum.java.sun.com/thread.jspa?threadID=5142201&tstart=0Post this code there (and use code tags).
masijade.a at 2007-7-9 22:51:53 > top of Java-index,Java Essentials,Java Programming...