jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes RS232 and Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "RS232 and Java" Watch "RS232 and Java" New topic

RS232 and Java

Cory Hartford
Ranch Hand

Joined: May 16, 2011
Posts: 85

Just wanted to share my experience with the ranchers in case someone may have deal with this. It is not readily apparent when googling what someone has to do in order to connect to and communicate with serial ports. Javax.com, from what I understand is deprecated, although people seem to use it with varying degrees of success. The other option that I found was RXTX. I am using Ubuntu 32bit and Eclipse; my need was to use RS232. To use the API, download the Linux/x86 archive from the Downloads page and point your build path to the jar file which resides in the extracted folder. In addition, you have to associate a native .so file with the rxtx.jar file in order for the code to access the OS devices. For whatever reason, the only packed .so files were for 64 bit OS'. Upon running the file I got an ELF (EFL?) error which apparently means I was using a 64bit .so file on a 32 bit machine. I poked around their "toybox" directory and found a Linux 386 .so file that you can find here. Point to that .so file in the rxtx.jar file in hte native code path (In eclipse, Project Build Path). After that, I used this example to help me test and learn the API.

In most cases, I would recommend getting a Rs232 to Ethernet Server, assign it an IP and go to town using socket connections. It's a far more flexible solution imo.

In this case, I had a device that had an embedded USB to serial drive so it was connected to a USB port, yet the OS recognized it as a COM port; specifically /dev/ttyUSB0. The rxrtx api helped me access and communicate with the device.

Hope this helps folks!

‎"The greatest of all weaknesses is the fear of appearing weak." - JB Bossuet
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

Thanks for sharing your knowledge.

ELF (Executable and Linkable Format) is a common file format for executable programs and libraries that's used on several Unix-like operating systems, including Linux.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link: http://aspose.com/file-tools
subject: RS232 and Java
jQuery in Action, 3rd edition