COM Port Error: Port Not Found

That’s weird, the code doesn’t work for me. This is the error:


RuntimeException: Error opening serial port COM5: Port not found
RuntimeException: Error opening serial port COM5: Port not found
RuntimeException: Error opening serial port COM5: Port not found

Update: The code works only with an Arduino board (specifically, Arduino UNO). But with other boards (like a local one, gizDuino), it does error.

Edit: Is there any way I can detect when the Arduino is disconnected?