java - How Would I Export My Code Correctly In Eclipse -
i right click on project press export press runnable jar file , export when launch it, has clear screen in eclipse shows image.
how fix this?
i've tried numerous posts , did when try put .jar file in images folder , launch jar still launches no background-image.
i had same issue. took me bit find answer. here answer found. save images in seperate folder somewhere in src folder , add build path. then, since images static can access this: bluesprite = imageloader.bluesprite; don't forget call imageloader.loadimages() too.
final public class imageloader { public static bufferedimage bluesprite; public static inputstream load(string path) { inputstream input = imageloader.class.getresourceasstream(path); if (input==null) { input=imageloader.class.getresourceasstream("/"+path); } return input; } public static void loadimages() { try { bluesprite= imageio.read(imageloader.load("explosionsheetblueshort.png")); } catch (exception e) { joptionpane.showmessagedialog(null, "error loading images. contact admin support"); e.printstacktrace(); } } }
Comments
Post a Comment