Crash-Causing Error with trying to display Lives

I have been trying to make a space-shooter type game, and I have been coding lives (which work until I try to display them). My code to display the life count is

Player p;
void draw()
{
 text("Lives:", 100, 100);
  text(p.getLives(), 100, 145);
}

class Player
int lives
{
Player(float x, float y0{
    lives = PLAYER_LIVES;
 }
public int getLives() {return lives;}
}
// in a separate tab
final static int PLAYER_LIVES = 5;

Obviously this is very shortened but this code works without the text line, with the text line, my program crashes and I get an error message:
Could not run the sketch. (Target VM failed to initialize)

text(str(p.getLives()), 100, 145);

Do you have setup and size()?

My setup is fullscreen(); and other irrelevant code. Even with a set size, it still happens.

Your code had many errors, so it didn’t run in the first place. I doubt you ever tried this version

My version

this version runs.


Player p;

// 
final static int PLAYER_LIVES = 5;

void setup() {
  size(665, 664);

  p=new Player(111, 222);
}

void draw() {
  background(0); 
  text("Lives:", 100, 100);
  //  text(p.getLives(), 100, 145);
  text(p.getLives(), 100, 145);
}

// ============================================================

class Player {
  int lives;

  Player(float x, float y) {
    lives = PLAYER_LIVES;
  }

  int getLives() {
    return lives;
  }
}
//