1

I am trying to export my Java project using Eclipse's function but when I run it, it only shows the background, no external files. I used customized Checkboxes and Button, but they don't show up. Running it from Eclipse works perfect. This is the hierarchy for my Game:

.settings(folder)
bin(folder)
src(folder)
.classpath
.project
some .png files 

This is how it looks in eclipse. I don't know what is with the red exclamation mark on Game.
screenshot

These are the steps I took in creating the runnable JAR file:

  1. I added my pictures to the Build Path (Skipping this step has the same effect)

  2. I clicked Export - Runnable JAR file:
    screenshot

  3. Then:
    screenshot

  4. When I clicked finish, I had no warnings:
    screenshot

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
zaa
  • 79
  • 8

2 Answers2

0

Why did you put all those images as referenced libraries? You should just put them in the src folder.

Any way, have you specified the main class when exporting the executable jar file? Can you explain what happens when you try to execute the generated jar file?

These warnings may not be related to problem. But if you show them, it may be easy to check.

jgesser
  • 243
  • 2
  • 7
  • I removed them from referenced libraries and sent them to the src folder. Still same thing. The warnings are related, didnt knew : http://imgur.com/aIYqjHg These three files are the ones that have to show on execution . – zaa Feb 22 '15 at 10:52
  • These warnings where related to the fact you have put images as referenced libraries. After removing them from referenced libraries and put then into the src folder, these warming should be gone. – jgesser Feb 22 '15 at 11:00
0

If I didn't get it wrong, Eclipse will only pack things in bin to the jar file. So you got two options:

  1. Leave things as it is, but when deploying, put the images in the same folder with the jar file.
  2. Put your images in src (so it would be copied to bin and hence packed) and change your way to access your image: get the URL with getClass().getResource() and read from the URL with something like Toolkit.getDefaultToolkit().getImage().
johnchen902
  • 9,531
  • 1
  • 27
  • 69