Export Project with Images

0

So I did a game in Eclipse and I'm trying to export it to a jar file only to no avail. Export works, but the images do not go together at all ... Here is an example of how I am instantiating the images:

private Image imagem;
ImageIcon a = new ImageIcon("caminho");
imagem = a.getImage();

Yes, the images are inside the SRC folder.

    
asked by anonymous 21.06.2016 / 20:33

1 answer

0

This error may be related to how you are exporting your jar. Or maybe how you are setting the path to your image. This means that your images are being exported to the jar, but they are no longer on the path you defined in development.

I recently had the same problem. Here's how I solved it:

1 - First you create a folder in the project root directory:

2-Thenyoucandefineaconstantthatholdsthebasepathofyourproject.UsingthevariableSystem.getProperty("user.dir") you transfer to jvm the responsibility of passing the path to the directory of your project. Regardless if you are in development or production.

    
22.06.2016 / 00:56