Java coming to the main distro

To the powers that be:

I noticed that Java is making it’s way into the main distro on this page:

This is very exciting news for me. While I have been running Java on there, it’s lack of hardware interface support doesn’t make it ideal for building systems that need to communicate with external hardware. Just access to a UART channel would be a huge win. The RxTx project mentioned allows for this and is compiled for a great many different platforms. It provides native C libraries that allows access to the UART channels.

While I am Java guy, my C skills leave something to be greatly desired. There is a small .so file that is needed. They have a project called “ToyBox” which compiles like 38 different versions of this file for all the different platforms. I have tried all Linux iterations on the BeagleBone but have yet to have any success interfacing with it. Mostly getting C errors I don’t understand. (Sorry I don’t have an example handy).

I have used these on windows with much ease. It looks like it would work easily for a common processor architecture on Linux.

Might I suggest that you add the RxTx libraries to your package list.

Anyone been working on this?

RxTx Main Site:
RxTx ToyBox (compiled for many versions):

If anyone knows a good article on compiling .so files from C for a java guy that would be helpful too.



opkg update ; opkg install rxtx openjdk-6-jre

OMG OMG OMG!!! Ok, yes I know I sound like a little girl, but this is awesome!!!

Ok, I am going to put my proof of concept code on my bone and see what I can get done. I will post results when I am done.

Thanks Koen!!!



Ok, so I am getting the same thing when I install it via opkg as I was when installing it by hand.

When I try to run the code I get the following stack trace:

java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-6-openjdk/jre/lib/arm/ /usr/lib/jvm/java-6-openjdk/jre/lib/arm/ ELF file OS ABI invalid thrown while loading
Exception in thread “main” java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-6-openjdk/jre/lib/arm/ /usr/lib/jvm/java-6-openjdk/jre/lib/arm/ ELF file OS ABI invalid
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(
at java.lang.ClassLoader.loadLibrary(
at java.lang.Runtime.loadLibrary0(
at java.lang.System.loadLibrary(
at com.greggharrington.flyingtoaster.RxTxPOC.main(

It’s the first line of code that accesses the RxTx library:

Enumeration thePorts = CommPortIdentifier.getPortIdentifiers();

This is the same error I was getting when I installed it by hand before. I took the following debugging steps:

  1. Uninstalled rxtx
  2. Uninstalled java (getting rid of any thing I might have done)
  3. Installed java and rxtx (as described above)
  4. Same error

Any thoughts?



Note: I have decided to go with a fresh install and upgrade to the latest version of Angstrom. I am currently running the shipping version on the A4. I think it’s about 5 months old. Not sure if I need todo this or not, but I have wanted to anyway.

More updates:

With a fresh install of the latest Angstrom distro I get the following error:

java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading
Exception in thread “main” java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
at java.lang.ClassLoader.loadLibrary(
at java.lang.Runtime.loadLibrary0(
at java.lang.System.loadLibrary(
at com.greggharrington.flyingtoaster.RxTxPOC.main(

After trying to run my code. It has been my experience that this is the result of the .so file not being in the /usr/lib/jvm/java-6-openjdk/jre/lib/arm directory. I have downloaded all known copies I can find of the file that I have used on other linux and windows machines. The opkg install rxtx doesn’t seam to install this file and I can’t seam to find the jar file either. I even did a “find / | grep -i rxtx” to see if I could find it. Nothing. When I use the jar files I download I get a linking error:

Exception in thread “main” java.lang.NoClassDefFoundError: com/greggharrington/flyingtoaster/RxTxPOC
Caused by: java.lang.ClassNotFoundException: com.greggharrington.flyingtoaster.RxTxPOC
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
Could not find the main class: com.greggharrington.flyingtoaster.RxTxPOC. Program will exit.

This means it can’t find the jar file. Any way to tell what the opkg install rxtx does to the file system?

Thanks for all the help…



Ok, one more final update for the night… I have had some limited success with reading a USB port and none with reading a UART port. The UART port is actually the goal of this project as I am currently using python to proxy information to java via a socket.

Here is what I have done:

  1. Installed newest distro (not sure this made a difference, but needed to be done anyway)
  2. opkg update
  3. opkg install openjdk-6-jre
  4. opkg install rxtx
    4a. I had to copy all files from /usr/lib/jni/librxtx* to /usr/lib/jvm/java-6-openjdk/jre/lib/arm to make the libraries work at all. This was not done by the install rxtx above. Probably a better way todo this with a link if someone would like to comment on that.
  5. Run my program which basically just spits out the com ports. Output reads:

WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
RXTX Warning: Removing stale lock file. /var/lock/LCK…ttyUSB0
/dev/ttyUSB0 - Serial

Note: Changing the version of the jar file doesn’t get rid of the warning regardless. However, that is the USB device that is hooked up. It is spitting out a 9600 baud GPS signal from a UART to RS232 serial converter.

  1. When I run this on windows I come up with:


  1. However, when I change only the port ID to /dev/ttyUSB0 it comes up with the following on the BeagleBone:


It’s obviously getting something and parts of it are right. However, it’s not getting it correctly. I would post all my code up here, but it’s several files. Here are the biggies though:

This code spins up some stuff:

inBuffer = new StringBuffer();
outBuffer = new StringBuffer();

portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/ttyUSB0");

CommPort commPort =“test”, 2000);

SerialPort serialPort = (SerialPort) commPort;

serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

reader = new SerialReader(serialPort.getInputStream(), inBuffer);
writer = new SerialWriter(serialPort.getOutputStream(), outBuffer);

new Thread(reader).start();
new Thread(writer).start();

Then later this code reads it. This is the thread that gets started:

byte[] buffer = new byte[1024];
int len = -1;
try {
while ((len = > -1) {
if (pause) {

if(stop) {

String str = new String(buffer, 0, len);


} catch (IOException e) {

If anyone could provide insight into getting a direct UART connection or even fixing this problem I would grateful. I will be spending some more time with this and update you guys if anything comes up.