Jar does nothing!
Yes, another one of these threads, I am trying to export my program to jar in Eclipse 3.2.
I selected my project, and the package, and all of the resources within it. I export it to my desktop, and YES I DID include the Main class.
Ok, it seems to export to my desktop with no issues, I double click the jar file, and absolutely nothing happens. With a different program at least the window canvas opens up, but its black and displays no graphic images, and only the drawString's. What is going on!! I am having big time trouble exporting to jar, they need to make this easier!
# 4
Ok, sorry for the triple post, but I know "why" it is doing this. It cant seem to find my graphical images. I have made jars for two other programs, and it has found those images and they worked. But my program does not work it doesnt find the reference, yes I use a resource loader.
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");
}