Topics and trends related to the Java ecosystem with occasional random rants.

  • Sun
    August 19, 2011

Serial Port Communication for Java SE Embedded

James Connors
Principal Solutions Consultant

The need to communicate with devices connected to serial ports is a common application requirement.  Falling outside the purview of the Java SE platform, serial and parallel port communication has been addressed with a project called RXTX.  (In the past, you may have known this as javacomm).  With RXTX,  Java developers access serial ports through the RXTXcomm.jar file.  Alongside this jar file, an underlying native layer must be provided to interface with the operating system's UART ports.  For the usual suspects (Windows, Linux/x86, MacOS, Solaris/Sparc), pre-compiled binaries are readily available.  To host this on an alternative platform, some (hopefully minimal) amount of work is required.

Here's hoping the following notes/observations might aid in helping you to build RXTX for an embedded device utilizing one of our Java SE Embedded binaries.  The device used for this particular implementation is my current favorite: the Plug Computer.

Notes on Getting RX/TX 2.1-7-r2 Working on a Plug Computer

1. At this early juncture with Java 7, be wary of mixing Java 7 with code from older versions of Java. The class files generated by the JDK7 javac compiler contain an updated version byte with a value that results in older (Java 6 and before) JVMs refusing to load these classes.

2. The RXTX download location http://rxtx.qbang.org/wiki/index.php/Download has binaries for many platforms including Arm variants, but none that worked for the Plug Computer, so one had to be built from source.

3. Using the native GCC for the Plug Computer and the RXTX source, binaries (native shared objects) were compiled for the armv5tel-unknown-linux-gnu platform.

4. The RXTX "stable" source code found at the aforementioned site is based on version rxtx 2.1-7r2.  This code appears to be pretty long in the tooth, in that it has no knowledge of Java 6.  Some changes need to be made to accommodate a JDK 6 environment.  Without these modifications, RXTX will not build with JDK6

SUGGESTED FIX, most elegant, not recommended:
Edit the configure.in file in the source directory and look for the following:

    case $JAVA_VERSION in

and change the second line to:


Upon modification, the autogen.sh script found in the rxtx source directory must be re-run to recreate the ./configure script.  Unfortunately, this requires loading the autoconf, automake and libtool packages (plus dependencies) and ended up resulting in libtool incompatibilies when running the resultant ./configure script.

Instead, edit ./configure and search for the occurrences (there are more than one) of

    case $JAVA_VERSION in

and change the second line to:


Run './configure', then 'make' to generate the RXTXcomm.jar and platform specific .so shared object libraries.

5. You may also notice in the output of the make, that there were compilation errors for source files which failed to find the meaning of "UTS_RELEASE".  This results in some of the shared object files not being created.  These pertain to the non-serial aspects of RXTX.  As we were only interested in librxtxSerial.so, this was no problem for us.

6. Once built, move the following files into the following directories:

    # cd rxtx-2.1-7-r2/
# cp RXTXcomm.jar $JAVA_HOME/lib/ext
# cd armv5tel-unknown-linux-gnu/.libs/
# cp librxtxSerial-2.1-7.so $JAVA_HOME/lib/arm
# cd $JAVA_HOME/lib/arm
# ln -s librxtxSerial-2.1-7.so librxtxSerial.so

Now Java applications which utilize RXTX should run without any java command-line additions.

The RXTXcomm.jar file can be downloaded here.  To spare you the effort, a few pre-built versions of  librxtxSerial-2.1-7.so are provided at this location:

If you've gone through this exercise on any additional architectures, send them my way and I'll post them here.

Join the discussion

Comments ( 25 )
  • Ali Naddaf Friday, February 10, 2012

    Many thanks for including the compiled library, that saved me a huge headache.

  • Dan Friday, February 10, 2012

    Thanks Jim,

    Worked a treat... compiled nicely for armV7l (tegra2). Well... a few warnings and errors came up but it worked! i can send you the .so and .jar files if you like to make them available for this architecture.

    - Dan.

  • Jim Connors Friday, February 10, 2012

    By all means! You supply the binaries and I'll post them.

  • guest Thursday, March 22, 2012

    i am new to this can you please guide me how to use thisi need to send data through rs232 from pc

  • Jim Connors Tuesday, July 10, 2012

    Gary Collins recently got his hands on one of the much ballyhooed Raspberry Pi devices, and was kind enough to provide the native librxtxSerial.so share object for this armv6l based platform. It is now listed as one of the provided pre-build versions.

  • guest Monday, August 6, 2012

    Thank you for compiled library. Now I am able to combine my electronics with Qnap (environment temperature reporter). Greetings.

  • Greg Wednesday, October 3, 2012


    I have tried the librxtxSerial-2.1-7.so for ARMv6l based systems (e.g. Raspberry Pi), on my Raspberry Pi running OpenJDK 1.6 on Arch Linux

    Unfortunately, I don't believe it has the fix. I get "java.lang.UnsatisfiedLinkError: gnu.io.RXTXCommDriver.nativeGetVersion()Ljava/lang/String; thrown while loading gnu.io.RXTXCommDriver" which would be the message I believe if the .so did not have the fix.

  • guest Thursday, October 11, 2012

    Your problem may lie in the fact that the Raspberry Pi Arch Linux distro uses the armhf (hard float) ABI which is incompatible with the armel-based version of the librxtxSerial.so which was originally provided here. I've been patiently waiting and just received my very own Raspberry Pi. When I get a chance, I'll try compiling an armhf version under the Raspbian (armhf) distro.

  • guest Thursday, October 11, 2012

    Updated to include librxtxSeirial-2.1-7.so files for both armel and armhf based Raspberry Pi distributions.

  • guest Saturday, January 19, 2013

    Has anyone compiled and tested rxtxlib for the BeagleBone? I tried pre-built versions ARMv6 for armhf and it works 3 hours when crashed. This happened repeatedly.

    I would be very happy if somebody upload version that fits to BeagleBone.

  • guest Tuesday, March 19, 2013

    For Linux why not use socat and then use sockets from Java ?


  • guest Tuesday, March 19, 2013

    I posted earlier that rxtxlib with BeagleBone crashed within 3 hour use. I have found out that problem didn't focused on rxtxlib. Reason came up from Huawei E367 netstick that is used as dial-up modem. This device seems not not to be so reliable.

  • Philipp Tuesday, April 2, 2013

    Running RXTX as an OSGi bundle allows to dynamically choosing the right native lib to load based on system properties (see OSGi "Bundle-NativeCode" manifest tag).

    Unfortunately, running the Oracle JVM 1.7.0 does not allow to distinguish the version of the ARM processor (V.5/6/7) using the system propertie. The "os.arch" is just "arm". Also, for ARMv6 (Raspberry Pi), it should be possible to distinguish between HF and SF.

    How can the dynamic choice of the native lib be done?

  • Jim Connors Wednesday, April 3, 2013

    This is currently not an easy problem to solve. Ironically I wrote a related blog entry entitled "Is it armel or armhf?". In there you'll find a pointer to a Raspberry Pi forum entry which discusses your exact question.

  • guest Wednesday, June 18, 2014

    the website http://rxtx.qbang.org/ is not available now. anybody know how to download the native source ?

  • Jim Connors Friday, June 20, 2014

    Been meaning to do this for a while, check out this blog entry:

    Java Serial Communications Revisited


    Among other things it points to RxTx source code with some very minor modifications.

  • guest Thursday, March 24, 2016

    please add tag "raspbian" and "raspberry pi"

    thanks :)

  • Jim Connors Thursday, March 24, 2016

    Done. Added "raspbian" and "raspberry-pi" tag to this blog and the preferred, updated version - https://blogs.oracle.com/jtc/entry/java_serial_communications_revisited

  • guest Monday, February 20, 2017

    Can you provide librxtxSerial.so for armv8

  • Jim Connors Monday, February 20, 2017

    Check out this later blog on serial communications: https://blogs.oracle.com/jtc/entry/java_serial_communications_revisited

    In the article, the source code is provided with some modifications such that it should readily build on your platform.

  • Jaydeep Thursday, October 11, 2018
    can you please provide RXTXCOMM.jar for ARMv7l architecture ?
  • Jim Connors Thursday, October 11, 2018
    A later revision of this blog entry:

    points to a git repository which contains an AMRv7l build.


    Note: this was done a few years ago, so I have no idea if it's still relevant
  • William J. Powell Monday, July 22, 2019
    With the new ARMv8 architecture on the Rpi 4, do you think this will be possible to code for armv8?

    I use a raspberry pi with software that required it, and this was AWESOME because it works on the pi3b+. With the 4 released I was considering upgrading hardware, but it doesn't look promising.

    Thank you!
  • Jim Connors Friday, July 26, 2019
    Have you seen the following url?


    I'm not sure if there's a match for the latest Raspberry Pi 4 architecture. If not, if I could get my hands on one, I'd try creating a new build.
  • William Powell Sunday, February 16, 2020
    I would have literally no idea where to start. But I upgraded hardware and cant use my software anymore.

    I would pay for a pi 4b+ compatible version...
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.