Make a Simple GUI and Displaying Serial Arduino data got NullPointerException

I tried to print out the data with a simpler program, and the result is like this. The results shown by the processing console are the same as those displayed on the Arduino serial monitor. My program is attached below the photo
image

//Test Print data
import processing.serial.*;

Serial port;
String val;

void setup() {
  size(600, 360);
  background(255);

  port = new Serial(this, "COM8", 9600);
}

void draw() {

  textSize(15);
  fill(0, 255, 0);
  text("TEST PRINT DATA", width/2, height/2);
  
  if (port.available() > 0) 
  {  
    val = port.readStringUntil('\n');         // read it and store it in val
 
  } 
println(val); //print it out in the console
}