Serial connection between Processing and Arduino doesn't work

It is busy if another application is using the serial port such as :

  • Arduino SerialMonitor
  • Arduino Serial Plotter
  • And so on…

Your Processing code is sending data to the Arduino and the Arduino is sending the data back to Processing as a string.

Reference:
Serial.print() - Arduino Reference

Modified Processing code to receive the data to demonstrate that it is working:

import processing.serial.*;

// The serial port
Serial myPort;

byte b;

void setup() 
  {
  // List all the available serial ports:
  printArray(Serial.list());
  // open port
  myPort = new Serial(this, Serial.list()[0], 9600);
  delay(1000);
  }

void draw() 
  {
  try 
    {
    myPort.write(b++);  // Counts from 0 to 255 and repeats since it is a byte
    }
  catch(Exception e) 
    {
    // Print detailed error information to the console.
    System.err.println(e);
    e.printStackTrace();
    }
  //delay(50);
  
  if(myPort.available() > 0)
    {
    int incoming = myPort.read();
    println(incoming);
    }
  }

I also added a delay(1000) in Processing in the setup() to allow the Arduino to reboot before sending data and flooding the buffers.

Related topic:

I only modified your code to show what it is doing as is.
You still have some exploration to do to understand serial communications.

:)