Error: NullPointerException

Hello,
I have a problem to solve this coding in Java in 16th line, show me an error: NullPointerException. What can I do? Below is the code:

import processing.svg.*;
PImage img;
float theta= 31;
float k = 11;
float r = 500;
float x1, x2;
float y1, y2;
float RATE=1;
 
void setup() {
  frameRate(5);
  size(800, 800);
  strokeWeight(5);
  beginRecord(SVG, "draw.svg"); 
  img = loadImage("IMG3936.jpg");
  image(img, 338, 450);           //image(img, 0, 0);
  x1= cos(k*theta)*cos(theta)*r+width/2;
  y1= cos(k*theta)*sin(theta)*r+height/2;
}
 
void draw() {
  theta += RATE;
  x2= cos(k*theta)*cos(theta)*r+width/2;
  y2= cos(k*theta)*sin(theta)*r+height/2;
  line(x1, y1, x2, y2);
  x1=x2;
  y1=y2;
 
}
void keyPressed() {
  if (key == 'q') {
    endRecord();
    exit();
  }
}

Thank you.

This line image(img, 338, 450); ?

Then loading of img didn’t work. Check if e.g. the spelling on the Hard Drive is correct for "IMG3936.jpg", it’s case sensitive or whether it’s jpg or JPG or even .jpg.jpg

Thank you!