0

I am writing a simple game in Eclipse (Java), it requires some images. It works fine in Eclicpse, but when I export it (as a runnable jar) there are no images (just empty places instead of them). I have a source folder called "images" in the project, and I adress the images this way: "images/name.png". THe images are exported right into the jar. I have tried placing images folder in an resource folder, still didn't work. I've also placed the images in different places in the jar, didn't work. How do I make Eclipse export the project correctly? (I'm just a begginer, so I don't know which information should I post)

1 Answers1

1

If you want to include and access resources as images or configuration files from a runnable jar, you have to place them in your source folder to include it. Alternatively you could provide the full path to the resources, which of course makes it difficult to port to other systems...

ClassLoader classLoader = getClass().getClassLoader();  
File file = new File(classLoader.getResource("file/test.xml").getFile());

http://www.mkyong.com/java/java-read-a-file-from-resources-folder/

Marvin Emil Brach
  • 3,984
  • 1
  • 32
  • 62