Java Comm Serial API How-To for Linux

Using RXTX and JCL


Special thanks to Trent Jarvi and Kevin Hester for putting together RXTX and JCL.  These two gentlemen have done an excellent job of porting the original Sun Java Comm API to the Linux OS.  However, with all due respect, and not to be insulting, their installation documentation leaves much to be desired.  This is the primary reason I have chosen to put this document together.

Getting Started

Before insalling the Comm API on your Linux box, be sure you have a JSDK installed.  You can obtain a JSDK for your version of linux from or Sun Microsystems.  To install and configure Java in Linux, please follow the instructions provided here.

For the purposes of this paper, it will be assumed that you have installed a JSDK and it is located in:


And java is then located in:


If your setup is different, please adjust accordingly. 

Installing RXTX

First, obtain the RXTX bins package from:
                        (In IE, right click and "Save Target As")

Decompress and Untar this package:

/bin/gzip --decompress rxtx-bins.1.tar.gz

/bin/tar xf rxtx-bins.1.tar

At this point, you'll have an rxtx-bins.1 directory.  Next, you'll need to copy the shared objects into your java installation:

cp rxtx-bins.1/1.4/i386-pc-linux/ /usr/java/j2sdk1.4.0/jre/lib/i386/

cp rxtx-bins.1/1.4/i386-pc-linux/ /usr/java/j2sdk1.4.0/jre/lib/i386/

If you are installing on an architecture other than an x86, you'll need to adjust both the /i386-pc-linux/ and the /i386/ accordingly.

Next, you'll need to install the jcl.jar file:

cp rxtx-bins.1/1.4/jcl.jar /usr/java/j2sdk1.4.0/jre/lib/ext/

At this point, the RXTX installation is complete.

Installing Comm

The final step to getting the Java Comm API working under Linux, is to install the Comm API itself.  At this point, you have all of the necessary kernel-level drivers installed.  Because Linux is a form of Unix, the authors of RXTX and JCL have wisely decided to reuse sun's solaris (unix) comm library.  At this point, you must download and install this library:  

Make sure you choose the Solaris/SparcTM version.  Next, you must Decompress and Untar this package:

/bin/gzip --decompress javax_comm-2_0_2-solsparc.tar.Z

/bin/tar xf javax_comm-2_0_2-solsparc.tar

Next, you'll need to install the comm.jar file:

cp commapi/comm.jar /usr/java/j2sdk1.4.0/jre/lib/ext/

At this point, we are almost finished.  We just need to create the properties file that the Comm API will use to load the drivers (.so files).  To create this file, type the following command:

/bin/echo > /usr/java/j2sdk1.4.0/jre/lib/

Congratulations!  You have installed the Linux Comm API.


While windows uses COM and LPT designators for port identifiers, Linux is a bit different.  Use the following table to identify your ports:

Port Windows port identifier What you use in Linux
Serial Port 1 COM1 /dev/ttyS0
Serial Port 2 COM2 /dev/ttyS1
Parallel Port 1 LPT1 /dev/lp0


Several people have emailed me and reported that they get the following error:

Exception in thread "main" java.lang.VerifyError: (class:
gnu/io/RXTXPort$SerialOutputStream, method: write signature: ([BII)V) Illegal
use of nonvirtual function call

I personally have not experienced this problem, but if you encounter this error, you can work around it by adding -noverify to your command line:

java -classpath your classpath -noverify your class

Also, it has been suggested that recompiling the jcl with the java compiler you have chosen will resolve this issue.  As I have never experienced this verification problem, I have no way to test this.  It should also be noted that the purpose of this paper is to be a quick and easy way to get serial and parallel port access in Java on Linux.  Most of the instructions on this page as well as the VerifyError are irrelevant if you chose to download the RXTX source and do a manual compile and installation.

Other Resources

  1. Trent Jarvi's RXTX Homepage.  (
  2. Kevin Hester's JCL Homepage.  (
  3. Sun Microsystem's Java Comm FAQ.  (

Reader Comments:

02/07/2016 1:44 AM - echo wrote:
Smacking good!

01/01/2016 3:55 PM - hEXoCZDPMe wrote:

12/31/2015 11:31 AM - wWsepspFTK wrote:

11/28/2015 2:53 PM - crorkservice fiverr wrote:
8kyPfX This is one awesome article post.Really looking forward to read more. Awesome.

11/08/2015 8:52 PM - crork service wrote:
Ix8lTk wow, awesome article.Thanks Again. Will read on

10/16/2015 6:39 AM - backlinks wrote:
BpwjJe A round of applause for your blog.Really thank you! Cool.

10/14/2015 3:41 PM - Joachim wrote:
Hi, I am very sorry for the trouble you have. I am arfaid that I may not offter you an English menu. Basically, first solider all the leds, the 64 leds in each layer share the same anode, while the 8 leds in each column shared the same cathode. So there are 8 anodes and 64 cathodes on the board.About programming, if you are using the Xuping's version, plug the USB cable, and you would find a serial port on your PC. Then you may send 2 bytes, like 0xf1 0 00 , which refers to turn off all leds, 0xf1 0xff means turns all leds on. There are other 2 commands, 0xf1, 0xf2.There is a blog about 3D8 driven by arduino. There is a sample code there. Wish it would make more sense to you.

09/28/2015 8:37 AM - seo service crork wrote:
z2ayUp Shiva habitait dans etait si enthousiaste,

08/03/2015 10:39 PM - crorkz com wrote:
i3qqS2 Thank you for this impressive report. I am refreshed following reading this. Thank you!

08/03/2015 5:01 PM - crorkzz wrote:
OFyAzf I truly appreciate this post.Much thanks again. Keep writing.

06/09/2015 9:55 PM - crorkzz linkbuilding wrote:
jClE8U Really enjoyed this post.Thanks Again. Really Cool.

05/06/2015 1:08 AM - crorkservice wrote:
DZO5eb excellent post, very informative. I ponder why the opposite specialists of this sector don't realize this. You should continue your writing. I'm sure, you have a huge readers' base already!

04/14/2015 10:43 AM - ??????? ???????? ????? ??????? wrote:
Very interesting. I think you can and stay.,

04/14/2015 10:41 AM - nod32 ????? 2013 wrote:
What is this?,

04/13/2015 9:03 PM - ??????? ????? ?????? wrote:
original news,

04/13/2015 9:01 PM - nod32 ?? ????????? ????? wrote:
And how much?,

04/13/2015 9:50 AM - ??????? ????? 1 ??????? wrote:
I'm sure it will interest many,

04/11/2015 6:46 PM - ??????? ??????? ??????? ????? wrote:
I believe that it is not so,

04/11/2015 6:44 PM - ??????? ????????? ????? ??????? wrote:
I believe that you are wrong,

04/11/2015 8:01 AM - ?????????? ????? ??? nod32 4 wrote:
What is this?,

04/11/2015 7:59 AM - ????? ????????? ??????? wrote:
?Excellent site! Thank U!,

04/10/2015 6:51 PM - ????? ??? nod32 ???? wrote:
Why is everything so difficult?,

04/10/2015 6:51 PM - ??????? ????????? ????? ?????? nod32 wrote:
?Excellent site! Thank U!,

04/10/2015 6:48 PM - ??????? ????????? ????? ??????????? wrote:
Very interesting. I think you can and stay.,

04/10/2015 6:48 PM - nod32 ????? ?????? 2012 ????????? wrote:
I believe that you are wrong,

04/10/2015 1:50 AM - ????? ?????????? nod32 ??????? wrote:
?Excellent site! Thank U!,

04/10/2015 1:46 AM - ????? ??? nod32 ?? 2017 wrote:
original news,

04/09/2015 4:22 AM - ?????????? ????? ??? nod32 wrote:
I believe that it is not so,

04/08/2015 8:49 AM - Vaselir wrote:

04/08/2015 8:39 AM - Vaselir wrote:

12/28/2014 1:44 AM - David wrote:
So, I've been playing with Java and RXTX.I was able to get my new sotrwafe to transmit out of the USB-serial converter last night. It seems easy enough to handle serial communications. One of my worries was integrating RXTX into my application, but that seemed to go smoothly enough once I figured out how to assign paths etc.The class seems to duplicate javax.comm, so any regular serial call will also just plain work. Pretty neat. This means existing reference-material on javax.comm will probably apply to RXTX.I hope java handles the data as cleanly and transparently as C++ did. One concern relates to buffering, etc.RXTX does have support for Linux (was specifically designed to support this first!), Mac OS X, and Windows. You have to use the appropriate .DLL or file depending on platform.I'll be interested to know how truly portable my stuff is, although admittedly there might not be much demand for it. I think portability is a noble goal though for open source sotrwafe.I've considered Real Basic for this task, mainly for its Rapid Application, but the costs are too prohibitive. I've used RB before, and it is pretty decent.

10/24/2014 8:48 AM - Josiah wrote:
Have you got any ? <a href=" ">purchase bimatoprost ophthalmic solution 0.03</a> None of this would have seemed possible after McIlroy shook off another slump to lap the field in a second major victory at last year??????s PGA. The incredible display of golf at Kiawah secured him the No. 1 spot in the world rankings, since reclaimed by Woods, with the anticipation that he would be collecting majors in routine fashion. He would finish the year ridiculously hot with four wins in his last six events and a successful Ryder Cup.

10/24/2014 12:53 AM - Elizabeth wrote:
Very funny pictures <a href=" ">lumigan bimatoprost eye drops</a> "This is where the rubber meets the road; we have less than 15 hours to get things done," Bryant said Thursday morning before bargaining began. She said they were "this close to reaching a deal" before BART withdrew its proposal the day before.

10/24/2014 12:53 AM - Jesus wrote:
Could I borrow your phone, please? <a href=" ">purchase bimatoprost online</a> Google's business, like rivals Facebook Inc and Yahoo Inc, has come under pressure as more consumers access its online services on mobile devices such as smartphones and tablets, where advertising rates are lower than on PCs.

10/24/2014 12:01 AM - Paige wrote:
What sort of work do you do? <a href=" ">buy bimatoprost online pharmacy</a> The Vueling planes on firm order are due to be deliveredbetween 2015 and 2020, subject to approval from IAG'sshareholders, and will replace some of Vueling's existing fleetof 70 A320s as well equip the low-cost carrier's continuedexpansion.

10/23/2014 6:59 PM - Melanie wrote:
Stolen credit card <a href=" ">bimatoprost for cheap with no prescription needed</a> Its gamble paid off; yields have fallen back globally and byissuing this week, Bahrain gained a first-mover advantage,satisfying pent-up demand. During the market's two-month hiatus,a $630 million aircraft leasing deal from Emirates airline wasthe only major activity in the Gulf.

10/23/2014 6:59 PM - Maya wrote:
Will I have to work shifts? <a href=" ">buying generic bimatoprost</a> A livery cab driver fatally stabbed a man after attacking another man with a knife and a baseball bat during a wild spat outside a Queens bodega early Saturday ?????? then drove away from the scene, cop sources said.

09/15/2014 5:16 PM - AA wrote:
The websites are not available anymore! I need to upgrade a java application, which has been originally using RXTX, but now with windows 8 and 64 bit system it cannot write through the port, although it can recognize it as a read port. Does any one have any idea how to fix it?we are using a USB-serial converter.

07/01/2014 6:10 AM - Jason wrote:
good article

06/09/2014 2:57 AM - Pharma908 wrote:
Very nice site!

05/31/2014 2:36 PM - Johnk441 wrote:
Hi! Someone in my Myspace group shared this website with us so I came to look it over. I'm definitely loving the information. I'm bookmarking and will be tweeting this to my followers! Great blog and terrific design and style. gafcaddeaaka

03/31/2013 3:31 PM - Jub16 wrote:
I don't know rxtx. ..I want to use in my project. .tell me from where to get started for beginners.

10/10/2012 11:38 AM - amjad wrote:
hi ,i use the javax.comm packet and run correctly, the question is how make my file to be .jar file, i use the old way like i write the mianfest.txt file and also don't work

10/08/2012 10:22 PM - Conny wrote:
Smart thinking - a cleevr way of looking at it.

07/14/2012 10:19 AM - Tom wrote:
<b>Nice article</b>

06/19/2012 4:24 PM - Camilo Duque wrote:
Hi, excellent content. I have a simple question: I'm using a laptop without rs232 serial port, instead I'm programming with rxtx through a USB port, so I need to know if the internal manage of communication is made by the kernel or rxtx driver or JVM? and I wonder if the real transmission occurs in RS232 or in USB protocol? Thanks a lot and congrats... Camilo

02/09/2012 11:16 AM - Alex wrote:
You saved me....

11/22/2011 11:17 PM - Nelson wrote:
Yap Nice job

11/19/2011 2:23 PM - Sam Ong wrote:
I have a Nomad Trimble with Windows Mobile. I am trying to connect it through the serial port. Can I use Linux on it as well?

11/10/2011 5:51 AM - nuwan wrote:
let me know how to download javax.comm api suitable for linux

09/15/2011 2:53 PM - greg wrote:
I get it now. You can't put any html in this comment system or it rejects the email without an error. The link to the comm code does not have a download. Seems that Wade needs to edit the page so that it reflects this? Maybe a link to where the code is now?

09/15/2011 2:50 PM - greg wrote:
Is this comment system broke too? I am trying to find the javax.comm api code. The link provided does not have a download. Does anyone know where I can get this download? The page was updated 9 days ago and I figure that oracle broke it.

06/11/2011 3:06 PM - Z.K. wrote:
Just curious, but if you are using Linux why not download the Linux version of the Java Comm API.

01/03/2011 11:42 PM - karan nage wrote:
i got problem at the time of implementation javax.comm for parallel port error is javax.comm class path were not found if any body hava solution plz post me contact no 9637624887

01/01/2011 8:13 AM - mitra wrote:
ops, I did the instruction but still same error like before while im sure about classpath, error: Exception in thread "main" java.lang.NoClassDefFoundError: net/tinyos/sf/SerialForwarder Caused by: java.lang.ClassNotFoundException: net.tinyos.sf.SerialForwarder at$ at Method) at at java.lang.ClassLoader.loadClass( at sun.misc.Launcher$AppClassLoader.loadClass( at java.lang.ClassLoader.loadClass( Could not find the main class: net.tinyos.sf.SerialForwarder. Program will exit. any help? thanks in advance.

12/13/2010 7:02 AM - bart wrote:
hi. i did almost the same in windows and it seems to work fine. the clue is: /bin/echo > /usr/java/j2sdk1.4.0/jre/lib/ this file is in ProgramFiles/Java/jre6/lib.. Project configured with rxtx and javax.comm as UserLibraries and added to buildPath in eclipse works fine

10/01/2010 8:16 AM - Valerione wrote:
hello, I followed the guide! I tried to run a little code to test the proper operation, but gives me this error: xception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.comm.SunrayInfo.isSessionActive()Z at com.sun.comm.SunrayInfo.isSessionActive(Native Method) at com.sun.comm.Portmapping.registerCommPorts( at com.sun.comm.Portmapping.refreshPortDatabase( at javax.comm.CommPortIdentifier.<clinit>( at Coordinator.Main.main( Java Result: 1

10/31/2009 2:00 PM - SchneiderIS wrote:
Pardon the blond moment. The permissions to write to the "lib" folder were needed. Then the file could be created.

10/31/2009 1:50 PM - SchneiderIS wrote:
In running your instructions I have run into a snag with the very last step for the Sun comm driver. When I try running: sudo /bin/echo > /usr/lib/jvm/java-6-sun/jre/lib/ I get the following error: bash: /usr/lib/jvm/java-6-sun/jre/lib/ Permission denied Looking in the "lib" folder there is no "" and when I search the drive for the file it does not exist. I have the latest download from Sun which is version 3 for comm and my java version is as follows: java version "1.6.0_16" Java(TM) SE Runtime Environment (build 1.6.0_16-b01) Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing) Do you have any suggestions as to what needs to be changed for this final command to register the driver?

05/10/2009 8:01 PM - Rzhbkqcf wrote:
Excellent work, Nice Design

11/19/2008 4:38 AM - ng_agi wrote:
it would be great if you have something similar for windows. there are a couple of words in wiki about rxtx win32 installation under eclipse, but i am still fighting with my installation...

11/18/2008 9:02 AM - MRI wrote:
the site wiki, and most of the links no longer lead to active sites. Is there a place to get the source for rxtx. I tried accessing the cvs site and that as well no longer functions. Advice?

08/21/2008 3:10 AM - Rajan wrote:
Well it works on linux. I need it to make it work on MAC OS(10.4). Will try to email you with some details, if you could provide any advise and help, would be appreciated.

08/07/2008 8:52 AM - WW wrote:
Point well taken, I've listened, and I've changed the site's text color :)

08/07/2008 2:54 AM - Claus wrote:
This website is hard to read, due to lightgray text on white background. Please, change this.

Post a Comment:

Your Name:
Your Comment:

Copyright 2002-2016 Wade Wassenberg
Last Modified: March 24, 2004. 
If you have questions, comments, or if you find any part of this document to be inaccurate or incorrect, please submit your feedback to