30

Possible Duplicate:
Java Serial Communication on Windows

Friends, I want to connect and transfer data to COM PORT (either virtual or original) in JAVA?

Community
  • 1
  • 1
Srinivasan MK
  • 801
  • 2
  • 10
  • 20

3 Answers3

40

This question has been asked and answered many times:

Read file from serial port using Java

Reading serial port in Java

Reading file from serial port in Java

Is there Java library or framework for accessing Serial ports?

Java Serial Communication on Windows

to reference a few.

Personally I recommend SerialPort from http://serialio.com - it's not free, but it's well worth the developer (no royalties) licensing fee for any commercial project. Sadly, it is no longer royalty free to deploy, and SerialIO.com seems to have remade themselves as a hardware seller; I had to search for information on SerialPort.

From personal experience, I strongly recommend against the Sun, IBM and RxTx implementations, all of which were unstable in 24/7 use. Refer to my answers on some of the aforementioned questions for details. To be perfectly fair, RxTx may have come a long way since I tried it, though the Sun and IBM implementations were essentially abandoned, even back then.

A newer free option that looks promising and may be worth trying is jSSC (Java Simple Serial Connector), as suggested by @Jodes comment.

Community
  • 1
  • 1
Lawrence Dol
  • 63,018
  • 25
  • 139
  • 189
  • 6
    A quick to note to others: if you were looking for a FREE way to use the serial port do not click the link. You are wasting your time. – ljbade Oct 24 '13 at 10:58
  • 5
    jSSC (Java Simple Serial Connector) is free, and I have found it extremely easy to use, and stable. Its developer is also very helpful. Highly recommended. – Jodes Jan 22 '14 at 13:53
  • 2
    It appears that serialio.com does charge a distribution fee (royalty) for commercial products - and a rather steep one at that! – KeithL Apr 26 '16 at 13:50
  • 1
    @KeithL: So it seems. They changed that since I used it years ago. Clearly, they felt they weren't being adequately compensated. Sad, really, it was, and presumably still is a best-in-class product. – Lawrence Dol Apr 28 '16 at 02:10
7

The Java Communications API (also known as javax.comm) provides applications access to RS-232 hardware (serial ports): http://www.oracle.com/technetwork/java/index-jsp-141752.html

Nayuki
  • 17,911
  • 6
  • 53
  • 80
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
5

An alternative to javax.comm is the rxtx library which supports more platforms than javax.comm.

freespace
  • 16,529
  • 4
  • 36
  • 58
  • 1
    `Java Communications API` is just that - an API. Sun reference implementation is very limited, but [SerialIO SerialPort](http://serialio.com/products/serialport/serialport.php) (an enterprise grade solution) does implement `Java Communications API` – Jarek Przygódzki Mar 17 '14 at 14:29
  • 1
    I understand that rxtx is an implementation of javax.comm – jacktrades Aug 28 '14 at 20:39
  • I've written an article about how to connect to a serial port using rxt, check it out: https://www.linkedin.com/pulse/integrate-weighing-scales-using-rxtx-library-dantas-de-oliveira/ – s_bighead Jul 04 '19 at 21:01