Ok, first of all, YES I know how to make jar files in eclipse. I have made sucessful jar files with several programs, like kev glass’ tutorials into jar form.
BUT, I am having issue with packing my program. My Hex Map program, is somewhat based off of the kev glass tut, but when I pack mine, and i excecute it through the command promt, so i can see what it prints, it prints some of my debug variables, then it says it cant find the graphic references, as i stated it should do in the program if it doesnt find the .pngs. YES, i thought that i included all of my graphics and resources in the program, but when i click my jar NOTHING happens, just those few prints in the command promt.
Heres how i handel images:
public Graphic getGraphic(String ref, String type) {
// if we've already got the sprite in the cache
// then just return the existing version
if (graphics.get(ref) != null) {
return (Graphic) graphics.get(ref);
}
// otherwise, go away and grab the sprite from the resource
// loader
BufferedImage sourceImage = null;
try {
// The ClassLoader.getResource() ensures we get the sprite
// from the appropriate place, this helps with deploying the game
// with things like webstart. You could equally do a file look
// up here.
URL url = this.getClass().getClassLoader().getResource(ref);
if (url == null) {
fail("Can't find ref: "+ref);
}
// use ImageIO to read the image in
sourceImage = ImageIO.read(url);
} catch (IOException e) {
fail("Failed to load: "+ref);
}
// create an accelerated image of the right size to store our sprite in
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
/** Keenan's Renderer Mod */
if (type=="oGRAPHIC") {
image = gc.createCompatibleImage(sourceImage.getWidth(),
sourceImage.getHeight(),Transparency.OPAQUE);
}
else if (type=="tGRAPHIC") {
image = gc.createCompatibleImage(sourceImage.getWidth(),
sourceImage.getHeight(),Transparency.TRANSLUCENT);
}
// draw our source image into the accelerated image
image.getGraphics().drawImage(sourceImage,0,0,null);
// create a sprite, add it the cache then return it
Graphic graphic = new Graphic(image);
graphics.put(ref,graphic);
return graphic;
}
I have loaded my images like this:
if (TEXTURE == GRASSLAND) {
return GraphicStore.get().getGraphic(
"\\ART\\TERRAIN\\GRASSLAND\\hex_green.png","tGRAPHIC");
}
