How to red serial communication to a textfile?

I found this little program on the web to save data sendt from the arduino to a textfile.

import processing.serial.*;

Serial mySerial;
PrintWriter output;

void setup() {
  size(100, 100);
  mySerial = new Serial(this, "COM3", 9600);
  output = createWriter( "data.txt" );
void draw() {
    if (mySerial.available() > 0 ) {
         String value = mySerial.readString();
         if ( value != null ) {
              output.println( value );

On arduino is running a simple code:

void setup() {
void loop() {

I get the following error in the processing terminal:

Error inside Serial.()

table Library

Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7 Unknown Application
at processing.serial.Serial.(Unknown Source)
at processing.serial.Serial.(Unknown Source)
at sketch_130802a.setup(
at processing.core.PApplet.handleDraw(
at processing.core.PGraphicsJava2D.requestDraw(

Any help on why it’s not working is appreciated.

Best regards from Kresten

I use Realterm to save to text files:

Works great. Thanks.
I still wonder why I can’t make the code work.