I'm using Netbeans to make a jfx app that talks to an arduino Uno. I have installed RXTX on my 64 bit OS X box and it seems to be working.
In the main controller of the application in the initialize() method I do this:
CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier("/dev/tty.usbmodem1d1111");
this.serialPort = (SerialPort) portId.open("Box App", 1000);
// this.serialPort.close();
This is great except that when I close the application's only window without calling that serialPort.close()
function, the app/jvm stays running in the background. I've tried overriding the dispose() method of the controller and adding Platform.exit()
.
Platform.setImplicitExit(true);
is set to true, explicitly.
Not sure what else I can do. If a user closes the app before the serial I/O is done, apparently it will just hang. How can I force the port closed when the application window is closed?