bufferedimage - Java using an image inside a .jar file -
i know questions have been asked before, have looked , tried lot of answers , none of them work. trying use image inside .jar file. image stored in directory /world/maps/map1.jpg.
bufferedimage bigimg; try { bigimg = imageio.read(getclass().getresourceasstream("/world/maps/" + name + ".jpg")); } catch(exception e) { system.out.println(e + ": error"); bigimg = null; }
thanks help.
forgot make clear class file in same directory image
if directory tree like:
someclass.class world |--maps |--image.jpg
you can use reference like:
someclass.class.getresource("./world/maps/image.jpg")
if class inside directory, add ../
path.
Comments
Post a Comment