serialEvent call

The following code should get you working.

import processing.serial.*;
Serial myport; // Create object from Serial class

void setup() {
// The next 3 lines are needed to call the event
String arduinoPort = Serial.list()[0];
myport = new Serial(this, arduinoPort, 115200);
myport.bufferUntil('\n');
}


// This function must be called serialEvent for this to work!!!
// it is part of the  processing.serial library and is defined this way
void serialEvent(Serial myport)
{
String inString = myport.readStringUntil( '\n' );

if(inString != null )
  {
  inString = trim(inString);
// process the code as you wish from here

}