If the linked example failed, then RXTX did not detect any serial ports on your computer. You may have a serial port on your computer, but one of the reasons it is not recognized by your OS may be because it is actually a USB serial port adapter and is recognized as a USB port.
If you are running Linux, serial ports usually look like this:
ls /dev/ttyS*
outputs:
/dev/ttyS0 /dev/ttyS1 /dev/ttyS2
an adapted port might look like this:
/dev/ttyUSB0
If you can see any output on your device connected to the network (for example, a POS printer or LCD), you can check it as follows:
echo 'hello' > /dev/ttyUSB0
and the device should show the string "hello" if it is connected to this port, and everything works correctly.
However, I would definitely recommend the Java library simple serial connector through RxTx. We tried both in a commercial POS application (> 1M tickets at this time).
RxTx is used for sequential printing. In the print script, the RxTx library was called sequentially and was used only to send data to the port. Only some of the serial flags were red to detect device health.
But due to its limitations, we simply could not use it to read input from a connected IButton. In an iButton script, it is expected that data will be received asynchronously from the port. There were constant errors and freezes when we tried to implement it using RxTx, but with JSSC it was implemented almost immediately.
source share