processing code dose not work

Can anyone help me with my processing code? I got a zero output in the text message ,and there are also some error:
Exception in thread "Thread-3" java.lang.NullPointerException
at processing.serial.Serial.serialEvent(Serial.java:221)
at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732)
at gnu.io.RXTXPort.eventLoop(Native Method)
at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575)

Here is my processing code:

import processing.serial.*;

import cc.arduino.*;

Arduino arduino;

int sensorPin = 7;
int sensorValue;

void setup() {
size(470, 280);
arduino = new Arduino(this, Arduino.list()[0], 9600);

arduino.pinMode(sensorPin, Arduino.INPUT);
}

void draw() {
sensorValue = arduino.digitalRead(sensorPin);
println(sensorValue);

}

If you are using Arduino with an USB cable, is very likely that the port isn't the "COM0". Check this, you have apparently a problem with the port.

It's not COM0 it is the first one it finds on the list. On a windows machine this is the first thing it sees which is normally the internal ones. On a Mac it is the last thing it had seen this is normally the last thing you plugged in. If you only have one internal COM port and are on a windows machine change:-
arduino = new Arduino(this, Arduino.list()[0], 9600);
to
arduino = new Arduino(this, Arduino.list()[1], 9600);