GitHub - Openmuc - JRXTX - The Java Serial Communication Library
GitHub - Openmuc - JRXTX - The Java Serial Communication Library
GitHub - Openmuc - JRXTX - The Java Serial Communication Library
openmuc / jrxtx
Dismiss
Join GitHub today
GitHub is home to over 20 million developers working together to host
and review code, manage projects, and build software together.
Sign up
gradle/wrapper updated gradle wrapper and main build file 5 months ago
native removed annoying warning if stale lock file is removed a year ago
build.gradle updated version of bnd tool used by build script 5 months ago
gradlew updated gradle version to 4.0 and made build.gradle changes to be com… 9 months ago
gradlew.bat updated gradle wrapper scripts and build file 2 years ago
README.adoc
jRxTx wraps the popular RXTX library for which development has been discontinued. jRxTx provides two kinds of APIs: 1) the
original RXTX API and 2) a new improved API.
It includes several bug fixes that do NOT change its API though
https://github.com/openmuc/jrxtx 1/3
02/04/2018 GitHub - openmuc/jrxtx: The Java serial communication library.
The Java build system is based on Gradle. This way it is easy to add the native libs to the jar.
The InputStream implementation provided by the original RXTX violates the contract of the general java.io.InputStream
interface. It has the following two problems:
A timeout does not throw an exception but instead returns -1. But according to the InputStream interface -1 should only
be returned if the stream is closed (i.e. the end of stream is reached).
A thread blocking in InputStream.read() cannot be interrupted by closing the associated serial port. Trying to close the
serial port while another thread is blocking in read() causes the close() function to block as well.
jRxTx provides an InputStream implementation that conforms to the java.io.InputStream interface and behaves very similarly
to the stream provided by java.net.Socket used for IP communication.
The event listener available in RXTX was removed in jRxTx because it is not needed for data stream reading.
While the Java library is platform independent, the native part of jRxTx needs to be compiled separately for different
processor architectures and operating systems. Because of the large variety of platforms jRxTx does not ship with any
precompiled native libs.
The jRxTx java library is compatible with the original RXTX native library. Thus you can also use the old RXTX native library or
the native library of other RXTX compatible projects such as NRJavaSerial.
1. You can install the native library so that the Java virtual machine can find it.
2. You can rebuild the jrxtx jar file to include the native library of your choice.
The Java library first searches a native library inside the jar file. If no compatible lib can be found it tries to load the libary from
the java.library.path (e.g. /usr/lib/jni).
Installation
Linux
The jRxTx native library is compatible to the RXTX native library. Therefore on Debian based distributions all you have to do is
install the package ‘librxtx-java’:
This will install the correct native library in /usr/lib/jni. Sometimes you might have to add a system property so that the JVM
finds it: -Djava.library.path=/usr/lib/jni .
The serial ports /dev/tty* are only accessible to members belonging to groups dialout and tty. You therefore have to add your
user to those groups. E.g. using:
Afterwards you have to log out and log back in in order for the group changes to become active.
https://github.com/openmuc/jrxtx 2/3
02/04/2018 GitHub - openmuc/jrxtx: The Java serial communication library.
Windows
On Windows you need to copy the native library of RXTX for your specific system to the folder that is in the java.libary.path.
To figure out the actual Java library path in your system, you can write a Java program that prints
System.getProperty(‘java.library.path’).
You can get the native library either from the last official RXTX distribution rxtx-2.2pre2-bins.zip or you can compile it on your
own from the source code.
Compile jRxTx
Linux
To compile the jRxTx Java library run the following command:
To rebuild the native library on Linux enter the folder native. Then run:
$ ./configure
$ make
Once you have compiled the native library you install it so that the JVM can find and load it. Alternatively you can compile the
jar with the native lib included:
This will create the jar file and include any librxtxSerial.so/.dll file found in the native folder. A jar file created this way can load
the native library from the jar.
https://github.com/openmuc/jrxtx 3/3