Skip to main content

RXTX or what about the serial interfaces

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2013-01-24


thank you for the hard float version for the raspbian on raspberry pi. (eJRE SE 8)
Everything is running fine except the serial interfaces. The librxtx-java in the debian repository is not working. For me that is crucial for the RPi because I need to be able to for example plug in a wifi/zigbee/etc usb dongle and work with that.

Can I expect this to be fixed soon or will I have to wait till Debian updates their packages?

If both optionas are not going to be possible .... how simmilar are the header files of ejre se 8 to ejre 7? With ejre 7 I was able to use the librxtx bundle.



Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2013-02-05

Hey James,

Actually librxtx-java works fine with 1.8.0. Here's details of what it took to get it working:

- Started with December 2012 hard float Raspbian image
- Installed jdk1.8.0 per
- Installed librxtx-java from the repository
- disabled console use of the port

All that was the easy part. I was trying to run an example that simply opened the port and copied data to/from the console for a quick test, found here:

Couple problems with the TwoWaySerialComm code above. One, they didn't import the serial classes, so add this to the top:


Next, the port they're using in the code is 'ttyUSB0', a USB port. If you want to use the UART on the Pi you'll need to change that to 'ttyAMA0'

Next, it never defines the port for rxtx so attempting to use ttyAMA0, ttyUSB0, etc. results in a ''. Add this somewhere ahead of where it opens the port... I started the main method with it:

String SerialPortID = "/dev/ttyAMA0";
System.setProperty("", SerialPortID);

Last, compiling requires that you specify specific classpath and library paths for RXTX. Use these commands to compile and run the example after the default installs above:

$ javac -cp /usr/share/java/RXTXcomm.jar:.

$ java -Djava.library.path=/usr/lib/jni -cp /usr/share/java/RXTXcomm.jar:. TwoWaySerialComm

Hope this helps - this'll get the basic example running.