Serial Communication with Java in 2021 (COM Ports)

Phil Girard
2 min readApr 20, 2021

--

I recently had to do Serial Communication with Java under a Windows operating system. I was a bit overwhelmed at first by all the options. However, most of the options are out of date. So I figured I should write a quick reference guides for people having the same issue.

Here are the options

jSerialComm (Best)

This option is pretty much the best right now. You can download a JAR file to get started quickly and they have excellent support for all the popular build systems (Gradle, Maven and such)

I decided to go with the JAR file. The download link was hard to spot:

The link to download the JAR is easy to skip if you read in diagonal

Also, here’s the link to their Github repository:

Example code with jSerialComm

Prints all the connected Serial devices:

This code outputs the connected Serial devices

Other options

RxTx

I have worked with RxTx in the past, and it was painful to deal with. You need to install a DLL for windows and external binaries on Mac. I also saw some complain about the stability of their API on forums online.

https://buy.serialio.com/collections/software

They look like a very good option if you want a paid premium solution. I never tried them.

javax.comm.*

Lot of documentation on the web still do references to javax.comm.*, however this API is deprecated in the recent versions of Java.

--

--

Phil Girard
Phil Girard

Responses (3)