I'm having problems when I pack my game into a jar, it won't load images right.. Read somewhere that I had to use class.getClassLoader().getResource() or something to get it right? Also, should I use BufferedImage?(is it faster?)

I'm using a singleton-class "BildeButikk" (ImageShop in english) to load images.

If you make the getImage function static then getClass() will not compile. Then you have to call getClass() on an instance on one of your classes. Call getClass() on a java.awt.Point and you might get the wront class loader. This might be what is tripping you up, Nimloth. Can also try Thread.currentThread().getClass().

resourcePath is the relative path to the image. Always use "/" as seperator and always start with a "/", even if it is in the root.

Make sure the image is in the correct place. Remember that path is case sensitive.

Have you tried without using executable jars? The manifest has a Class-Path attribute that might mess with your classpath. Try this instead:D:\projects\temp>java -classpath .;sajotris.jar YourMainClassHere

The problem is that the src object is null.. According to javadoc the read() method in ImageIO returns null if no registered ImageReader claims to be able to read the stream... My guess is that it can't find the image?

Example of s: "data/bilder/ting/box1.gif"

I'm using JBuilder X,.. The file structure in the jar-file:[SuperSpillet.jar]-data---bilder-----ting-------box1.gif-superspillet---BildeButikk

I now know that my problem is classpath-related.. If I move the data folder to the folder called classes(this is where JBuilder put my compiled files) then it works withgetClass().getClassLoader().getResource(...).. But the problem is that when I press "rebuild", JBuilder deletes all files in the classes folder.. I lost A LOT of my new graphics this way

So, I want to have the "data" folder in the project folder right next to "src" and "classes".. This works with jar if I add the following to the manifest:Class-Path: .;superspillet;

But it doesn't work inside JBuilder, but I guess it will when I figure out how to change the classpath.. Anyone know how to do this? If I go to project -> project properties -> classpathI see the classpath, but can't change it..

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org