Hey guys
I'm trying to export my game from eclipse to an executable jar. When I launch it in eclipse it works perfectly. When I export it nothing happens and when I launch it through console i get this:

http://img697.imageshack.us/img697/899/errordc.png

and I have main class

public class main {
 public static void main (String[] args){
	 BlueHarvest bh = new BlueHarvest();
 }
}

also my manifest points towards this class.

Try executing it with java -jar BlueHarvest.jar . If it still fails you probably need to fix up the manifest to specify the main-class attribute.

okay the java -jar something.jar helped alot. Now I have one more question. Its giving me another error which says that image icon variable is a null pointer. I think this could be why:

public void getNPCImage(){
		ImageIcon ii = new ImageIcon(this.getClass().getResource(character[charDirection]));
		image = ii.getImage();

		width = image.getWidth(null);
		heigth = image.getHeight(null);
	}
	public void spriteSetup(){
		//Forward
		character[0] = "../sprites/"+charChoice+"/forward_stand.png";
		character[1] = "../sprites/"+charChoice+"/forward_left.png";
		character[2] = "../sprites/"+charChoice+"/forward_right.png";
		//Left
		character[3] = "../sprites/"+charChoice+"/left_stand.png";
		character[4] = "../sprites/"+charChoice+"/left_left.png";
		character[5] = "../sprites/"+charChoice+"/left_right.png";
		//Back
		character[6] = "../sprites/"+charChoice+"/back_stand.png";
		character[7] = "../sprites/"+charChoice+"/back_left.png";
		character[8] = "../sprites/"+charChoice+"/back_right.png";
		//Right
		character[9] = "../sprites/"+charChoice+"/right_stand.png";
		character[10] = "../sprites/"+charChoice+"/right_left.png";
		character[11] = "../sprites/"+charChoice+"/right_right.png";
	}

but I don't know how I should fix...unlesss I should load up all the images. Im going to try that now I guesss.

this didn't work (example below) it works fine while still in eclipse but when exported to jar same error:

public void getCharImage(){
		//ImageIcon ii = new ImageIcon(this.getClass().getResource(character[charDirection]));
		for(int i =0; i < 12; i++){
			chars[i] = new ImageIcon(this.getClass().getResource(character[i]));
		}
		image = chars[charDirection].getImage();

		width = image.getWidth(null);
		heigth = image.getHeight(null);
	}
	public void charSetup(){
		//Forward
		character[0] = "../sprites/"+charChoice+"/forward_stand.png";
		character[1] = "../sprites/"+charChoice+"/forward_left.png";
		character[2] = "../sprites/"+charChoice+"/forward_right.png";
		//Left
		character[3] = "../sprites/"+charChoice+"/left_stand.png";
		character[4] = "../sprites/"+charChoice+"/left_left.png";
		character[5] = "../sprites/"+charChoice+"/left_right.png";
		//Back
		character[6] = "../sprites/"+charChoice+"/back_stand.png";
		character[7] = "../sprites/"+charChoice+"/back_left.png";
		character[8] = "../sprites/"+charChoice+"/back_right.png";
		//Right
		character[9] = "../sprites/"+charChoice+"/right_stand.png";
		character[10] = "../sprites/"+charChoice+"/right_left.png";
		character[11] = "../sprites/"+charChoice+"/right_right.png";

	}

Try adding a leading "/" in the call to getResource()

Try adding a leading "/" in the call to getResource()

Tried it, didnt work just gave null pointer...even in eclipse. I have no experience with utilizing resources in jar files. So im probably missing something obvious.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.