I think you are writing a Processing program that talks to the Arduino using the Arduino object.
This requires the program ‘Firmata’ to be running in the Arduino. Arduino IDE, File, Examples, Firmata, Standard Firmata. Compile, Load, wait for load to finish. Run Processing.
You will see there are lots of versions of Firmata. I’ve only used Firmata very briefly and don’t know what all the different versions are for.
You must have your Processing sketch stopped while you (compile and) load the Arduino.