Java Serial Port Api

  

Java serial IO driver. Contribute to BryanHunt/java-serial-port development by creating an account on GitHub. The official API for serial communication in Java is the JavaComm API. This API is not part of the standard Java 2 version. Instead, an implementation of the API has to be downloaded separately.

  1. Java Serial Port Programming Example
  2. Java Serial Port Api Key
Active3 years, 4 months ago

I've been looking around for a Java API that can communicate with serial devices on Windows/Win32 but many of the APIs I've checked out are either for Linux, too outdated, or just had bad critics.

Programming

Can someone recommend one to me that they've tried or knows about that is easy to implement on Windows XP?

dsolimano
7,6923 gold badges41 silver badges57 bronze badges
SteveSteve
8057 gold badges22 silver badges30 bronze badges

5 Answers

I started looking for the same thing couple weeks ago, and I've been very happy with the multi-platform RXTX library so far. Works with any Windows, Linux and OS X. Has a very clean, easy to understand API.

edit: RXTX is also open source.

Murat AyferMurat Ayfer
2,0946 gold badges23 silver badges26 bronze badges

Without reservation, I recommend Java Serial Port from serialio.com; I had significant stability problems with the Sun, IBM and RxTx serial package. SerialPort has been rock solid in production 24/7 for over 5 years.

They support the standard Java serial API, as well as their own alternative proprietary one. I would stick with the standard API though, unless you really need something theirs has that the standard one doesn't, just to keep your options open.

If there are more than one WattNode then the other units must be assigned a different address (e.g. Modbus rtu communication. Leave position 1 OFF and set position 2 ON to set the next unit’s address to 2).

Lawrence DolLawrence Dol
48.5k23 gold badges126 silver badges178 bronze badges

I've been using PureJavaComm for the last five years or so. It's actively maintained, and is a pure Java (via JNA) implementation. RXTX has let me down because of a lack of maintenance and numerous subtle problems.

Jason SJason S
112k140 gold badges505 silver badges843 bronze badges

Java is notorious for its flaky serial I/O support. At a previous job, we tried both RXTX and SerialIO for an application that streamed data at 56kbps from a Teknic servo controller, and found them to gobble up the CPU quite a bit. Perhaps for apps that don't require continuous streaming from a serial port, both of these libraries are good, but we didn't feel that streaming I/O from a serial port should be eating a sustained 15-30% of the CPU on the machine when it is much needed for other threads in the JVM that need to be responsive.

Instead, we created a server in C++ that would read the stream of data from the serial port on the servo, transform/packetize it and send it to our Java app in XML over a socket connection. The CPU load on the serial I/O server in C++? Barely creeping into 1% at its worst.

There are certain things Java does well - serial I/O, in my opinion, isn't one of them, depending on the type of application..

Ultimately, you should take even what I said with a grain of salt, and try both, RXTX and SerialIO (which is dirt cheap, like $50 or so for the java version) and if they meet your needs, go with it. Personally, I'd stick with SerialIO because it is supported and actively worked on. RXTX, not so much.

Martin NaskovskiMartin Naskovski

I've written an open-source Java library because none of the existing ones fit my needs (outdated, closed-source, hard to modify, un-maintained, ..).

It's called JSerial, it's MIT-licensed, and you can learn more here: https://github.com/thibautd/JSerial !

Currently only supports Windows, but I have plans for supporting Linux. You can easily modify the native part with the latest Visual Studio if you need.

Thibaut D.

Java Serial Port Programming Example

Thibaut D.
9863 gold badges12 silver badges27 bronze badges

protected by CommunityJun 1 '15 at 19:16

Serial

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Java Serial Port Api Key

Not the answer you're looking for? Browse other questions tagged javawindowsserial-port or ask your own question.