# I keep getting null pointer exception when using classes when playing audio

**URL:** <https://discourse.processing.org/t/i-keep-getting-null-pointer-exception-when-using-classes-when-playing-audio/23179>\
**Category:** Libraries\
**Created:** [August 11, 2020, 4:38am UTC](https://discourse.processing.org/t/i-keep-getting-null-pointer-exception-when-using-classes-when-playing-audio/23179 "2020-08-11T04:38:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon76195010](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anon76195010](https://discourse.processing.org/u/anon76195010)\
**Post date:** [August 11, 2020, 4:38am UTC](https://discourse.processing.org/t/i-keep-getting-null-pointer-exception-when-using-classes-when-playing-audio/23179/1 "2020-08-11T04:38:41Z")

</div>

So this is my main file (named `Testing`)

```auto
Minim minim;
Audio audio;

void setup()
{
  audio = new Audio();
  size(800, 800);
}

void draw()
{
  audio.drawShape();
  background(255);
  
}

```

And this is the `Audio` class file

```auto
import ddf.minim.*;
import ddf.minim.analysis.*;

class Audio
{
  final int BUFFERSIZE = 2048;
  AudioPlayer audio;
  Audio()
  {
    minim = new Minim(this);
    audio = minim.loadFile("audio.mp3", BUFFERSIZE);
    audio.play(); // This is where the nullpointer exception thing happens.
  }
  
  void drawShape()
  {
    ellipse(200, 400, audio.left.get(1)*800, audio.left.get(1)*800);
    ellipse(600, 400, audio.right.get(1)*800, audio.right.get(1)*800);
  }
  
}

```

I have the `audio.mp3` in the same directory as these two files. But why do I keep getting this error message:

```auto
NullPointerException
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.

```

Before I wasn’t getting it when I wasn’t uses classes, now all of a sudden why is this happening?
