I must admit I haven't used the isCurrentlyOwned() method, so maybe there is an issue with it? One problem I have noticed is that if you leave something running that has been used to communicate over the port then Java cannot subsequently get hold of it. For example if I run a QBASIC program and then exit QBASIC but leave the command prompt open that can cause Java problems. Are you sure everything else that might have had access to the port is completely shut down?
SCJP 1.4, www.gsi3d.org.uk
Joined: Jul 18, 2003
Ben; thanks for your reply. Yes, listing the ports works fine. That's waht the getPorts() method in the first line of code does. It returns COM1 and COM2 as serial ports.
I was thinking about other processes not letting go of the port too, to test it I did two things: 1) insert the code to check for port in use, and 2) rebooted and tried it first thing.
I'm really not sure how to proceed on this. Perhaps I should take this code out into an independent class and run it on another machine. Can't think of many more approaches...