java - Where do I store images so that an executable jar file can access them? -



java - Where do I store images so that an executable jar file can access them? -

i using eclipse create executable jar file of game created, when create jar , run it, images in game no longer show up. store images jar file can access them?

put them in jar, , utilize class.getresource, class.getresourceasstream, classloader.getresource or classloader.getresourceasstream access them. appropriate depends on else you're doing, might want like:

image image = new image(program.class.getresource("/images/foo.jpg"));

... program.class any class within same jar file. or if you're storing images in same folder classes (by time you're deployed) use:

image image = new image(gamecharacter.class.getresource("knight.jpg"));

that's relative resource name. (relative class in question.)

java eclipse image executable-jar

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -