0

I'm totally misunderstanding something about exporting a project to a JAR.

2 things are happening.

First, I get an alert while exporting the Runnable JAR File:

Exported with compile warnings: prj.Resources/classes/Person.java

My Project is called prj.HelloWorld. The main function resides here. It is also referencing another projects resources, which happens to be prj.Resources. (I added that project to the Java Build Path for prj.HelloWorld)

So, the Person.java class is performing just fine, but I still get the compile warning. What does that warning mean?

Second, when I double-click my helloworld.jar file, which I saved to my desktop, I don't see any images in the MenuBar Items. I'm calling icons from within both projects. When I run the compiler from inside Eclipse, everything shows fine.

-As I'm exporting the Runnable JAR File, I'm selecting the "Extract required libraries into generated JAR", under the Library handling option.

What am I doing wrong, with images?

coffeemonitor
  • 12,780
  • 34
  • 99
  • 149
  • Seems they are in wrong place. – Branislav Lazic Dec 18 '12 at 23:29
  • You're right. When I exported to the same directory as the prj.HelloWorld, it shows the images. – coffeemonitor Dec 18 '12 at 23:31
  • Have a look at my answer in this question: http://stackoverflow.com/questions/13258375/how-to-set-an-icon-to-a-jframe-when-using-createandshowgui-method/13259593#13259593 Thats the best way to add icons in your Java project. P.S. If you don't work with multiple packages, just add icons in default package. – Branislav Lazic Dec 18 '12 at 23:32
  • So, now I'm confused. If I want to send my friend the JAR file, how would he see the icons? I assumed the JAR would contain all dependencies to reference. – coffeemonitor Dec 18 '12 at 23:40
  • By extracting jar file with WinRAR. :) – Branislav Lazic Dec 18 '12 at 23:42

2 Answers2

1
Window -> Show View -> Problems

This will open up a view which will show any problems in the program. Warnings are not critical, but notices of possibly deprecated functions and other things that should be changed.

Matt Clark
  • 27,671
  • 19
  • 68
  • 123
  • This actually is helpful. I only had the Console open. Nice to see any existing warnings, even if they're not a big deal – coffeemonitor Dec 18 '12 at 23:37
0

The images are in wrong place/folder so that eclipse ignore them during the build process. If you don't have this folder(src/resources) try to create it and put your images in it

Festus Tamakloe
  • 11,231
  • 9
  • 53
  • 65
  • why not? what is your approach to this issue? – Festus Tamakloe Dec 18 '12 at 23:48
  • Because he will have to "carry" that `resource` folder with his jar file. Otherwise, icons will not be displayed. – Branislav Lazic Dec 18 '12 at 23:49
  • The thing I notice is that I see the images fine, running it in Eclipse. It's when I export the JAR that images don't show. The images do reside in the JAR, but not displayable in the program. It's obviously a path based issue. Just not getting it – coffeemonitor Dec 19 '12 at 00:23
  • I got more specific just now, in this post: http://stackoverflow.com/questions/13943913/eclipse-loading-icon-resource-error – coffeemonitor Dec 19 '12 at 00:53
  • nice. that is also what i try to explane. the answer will be more pretty if you put all icons/images in a folder whether than directly in src folder and get the icons with getClass().asResource(src/resources/save.icon) – Festus Tamakloe Dec 19 '12 at 01:01
  • getClass().getResources(src/resources/save.icon) – Festus Tamakloe Dec 19 '12 at 01:09