Trace: » laser » output » threads » plugins » cookies » userdir » xml_layer » dataobject » fileobject » serial_java
Working with serial ports in Java
gnu.io.*, RXTX and Java comm
The Java Communication API, or Java comm is necessary to talk to serial port from java.
There are several implementations of this API. The one written by SUN *no longer works on all systems. It is in package javax.comm.
RXTX serial and parallel I/O libraries supporting Sun's CommAPI|RXTX]] offers another implementation which supports all the standard operating systems and comes with in its own separate package, gnu.io; Otherwise, the API is completely identical to Java comm. You should read what's written on the RXTX download page. BEWARE: there are 2 “versions” of RXTX. One (RXTX 2.0) works in conjuntion with javax.comm, the other (RXTX 2.1) is completely cross platform and standalone.
You probably want the cross platform standalone one. RXTX 2.1 comes in package gnu.io. You're going to have to download the package and follow setup instructions on each machine that you want this to work on, because talking to the serial port involves some hardware drivers (dll) which you need to put in specific places on each machine. The RXTX site can help you. Go to the RXTX wiki, which has install information.
On Windows, you have to: (info copied from rxtx wiki)
Identify your Java Development Kit's folder. For version 1.6.0, this usually is
c:\Program Files\Java\jdk1.6.0_01\
- Copy rxtxParallel.dll to c:\Program Files\Java\jdk1.6.0_01\jre\bin\
- Copy rxtxSerial.dll to c:\Program Files\Java\jdk1.6.0_01\jre\bin\
- Copy RXTXcomm.jar to c:\Program Files\Java\jdk1.6.0_01\jre\lib\ext\
Java Programming - Javacomm alternative (MS Windows specific) helpful forum
Sending ASCII commands to serial port
BEWARE that JAVA uses Unicode, which is 2 bytes = 16 bits