Open Processing, create a new sketch and enter this verbatim:
import processing.serial.*;
println(Serial.list());
then run it (Ctrl+R). You should see output something like the following:
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
[0] "COM4"
In my case, I have one "serial" connection to an Arduino. My PC thinks this is called is COM4 (irrelevant) but, most importantly, it's entry zero [0] in the list of serial ports.
If you have more than one serial port you might see something like the following:
[0] "COM4"
[1] "COM5"
[2] "COM6"
If you do then you need to choose whichever enty (0, 1 or 2) is the one that corresponds to the serial port connected to your Arduino.
Then, in the line of code that says:
theSerial = new Serial(this, Serial.list()[0], 9600);
change the [0] to [n] where [n] is the port you've chosen.
n.b. you must ensure that Processing is the only application talking to your Arduino on this port. This means that you must close down your Arduino sketchbook before starting any of this Processing stuff.