user3318928 user3318928 - 2 years ago 89
Java Question

NullpointerException; Can't open file

I'm trying to make a soundboard and I wanted to add a class to make it run easier and I get more points with a class if I use it.

However I get a

and I would like to know why the problem happened. If someone can explain it to me that would be perfect.

occurs when calling `

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

PImage soundboard;
PImage [] array= new PImage[0];

sound sound1;

Minim minim;
AudioPlayer player;
Boolean player1= false;

void setup() {
minim = new Minim(this);
player = minim.loadFile("deadmau5.mp3");
soundboard = loadImage("sb.png");

void draw() {

void mousePressed() {
if (player1) {;
} else {

class sound {
float x = 1;
float y = 1;

void run() {

void draw() {

One more question that I must ask: when I rewrite code, sometimes it overwrites on my current code and I want to know how to stop that, even if I use space it still overwrites the code.

Thank you guys!

Answer Source

You didn't initialize the sound1 field, so it is null be default.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download