How to... RXTX on Mac

i'm following that guide but i don't know how to do this:

"Append the directory containing librxtxSerial.jnilib files into your DYLD_LIBRARY_PATH environment variable"

Could someone help me, please?

Well, could you start by explaining what you’re trying to do?
Serial communications to upload compiled sketches and send/receive
text from the arduino in the monitor worked for me with no
special installation steps. I just ran the newest and selected the
proper Board and Serial Port.

Could be that the documentation you are reading is out of date.

On my Mountain Lion 2010 macbook pro, DYLD_LIBRARY_PATH is unset. To see all environment variables,
go to the terminal and type set.

To append something to an existing environment variable, you
would do something like the line below. This is assuming you’re using BASH,
the default Linux, Mac shell. Other shells have different syntax.

export PATH="$PATH:/newstuff"

means add /newstuff to the end of what is currently in the variable called PATH.

If you just want to talk to an arduino over a serial link, ie. get sensor data or whatever your sketch is sending using Serial.print(), there is no need to use the Arduino IDE.

For example, at the terminal typing

cat /dev/tty.usbmodemfa141

spits out whatever is coming in on that serial device. (Your /dev/usbmodemXXXXX will probably be different. Connect the arduino and look to see what it is.)

This can easily be redirected to a file:

cat /dev/tty.usbmodemfa141 >log.txt

If you want an interactive session (you uploaded a sketch to make your arduino do something in response to stuff you type over the serial link):


screen /dev/tty.usbmodemfa141 9600

(9600 is the default baud rate.)

Thanks a lot for your wide reply!

This is the sketch i loaded on my Arduino Uno: (a simple light sensor)

int ledPin = 7;    // il LED e' collegato al pin digitale 7 
int sensorPin = 0;  // il sensore di luce è connesso al piedino analogico 0  
int sensorValue;    // variabile per memorizzare il valore rilevato dal sensore  
void setup()  
         pinMode(ledPin, OUTPUT);   // imposta ledPin come pin di output  
         Serial.begin(9600);    //inizializza la porta seriale  
         digitalWrite(ledPin, LOW);    // accende il LED  
void loop()  
          sensorValue = analogRead(sensorPin);  // legge il valore dal sensore  
          Serial.println(sensorValue);  // invia il valore al computer  
          Serial.println(" ");
          if (sensorValue > 600)
          } else digitalWrite(ledPin,LOW);

i would create a java application that receive the “sensorValue” data (from tty.usbmodemXXXXX) and than do something with it.

This is the java code i use:

import java.util.Enumeration;
public class ArduinoJava implements SerialPortEventListener {
    SerialPort serialPort;
        /** The port we're normally going to use. */
    private static final String PORT_NAMES[] = {
            "/dev/tty.usbmodemfa131", // Mac OS X
            "/dev/ttyUSB0", // Linux
            "COM3", // Windows
    /** Buffered input stream from the port */
    private InputStream input;
    /** The output stream to the port */
    private OutputStream output;
    /** Milliseconds to block while waiting for port open */
    private static final int TIME_OUT = 2000;
    /** Default bits per second for COM port. */
    private static final int DATA_RATE = 9600;
    public void initialize() {
        CommPortIdentifier portId = null;
        Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
        // iterate through, looking for the port
        while (portEnum.hasMoreElements()) {
            CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
            for (String portName : PORT_NAMES) {
                if (currPortId.getName().equals(portName)) {
                    portId = currPortId;
        if (portId == null) {
            System.out.println("Could not find COM port.");
        try {
            // open serial port, and use class name for the appName.
            serialPort = (SerialPort),
            // set port parameters
            // open the streams
            input = serialPort.getInputStream();
            output = serialPort.getOutputStream();
            // add event listeners
        } catch (Exception e) {
     * This should be called when you stop using the port.
     * This will prevent port locking on platforms like Linux.
    public synchronized void close() {
        if (serialPort != null) {
     * Handle an event on the serial port. Read the data and print it.
    public synchronized void serialEvent(SerialPortEvent oEvent) {
        if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
            try {
                int available = input.available();
                byte chunk[] = new byte[available];
      , 0, available);
                // Displayed results are codepage dependent
                System.out.print(new String(chunk));
            } catch (Exception e) {
        // Ignore all the other eventTypes, but you should consider the other ones.
    public static void main(String[] args) throws Exception {
        ArduinoJava main = new ArduinoJava();

so ok…i understand now that i don’t need [RXTX library](http://RXTX library), but i don’t understand why i got this error with the java code still:

java.lang.UnsatisfiedLinkError: /Library/Java/Extensions/librxtxSerial.jnilib:  no suitable image found.  Did find:  /Library/Java/Extensions/librxtxSerial.jnilib: no matching architecture in universal wrapper thrown while loading
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Library/Java/Extensions/librxtxSerial.jnilib:  no suitable image found.  Did find:  /Library/Java/Extensions/librxtxSerial.jnilib: no matching architecture in universal wrapper
	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 ArduinoJava.initialize(
	at ArduinoJava.main(

Anyway, i tried
screen /dev/tty.usbmodemfa131 9600
and it works fine, so it’s just a good start point for me :blush:

blah, blah ..../librxtxSerial.jnilib: no matching architecture in universal wrapper thrown while loading .....blah, blah

The problem could be 32/64 -bit silliness.

Look at this:

I am also having problems with librxtx-java on PPC linux and just don't use it. Maybe I'm just an old Moomintroll, but I think it is totally nuts to work with serial ports in java. This should be handled at a lower level by the operating system.

btw, if you don't want to use Arduino IDE, you can build everything from the command line using scons and SConstruct. (Look at the Arch Linux wiki on scons and arduino to see details.)

Yes i readed the post… but it don’t work with -d32 argument too. :frowning: