Re: Giving an application a window icon in a sensible way



Twisted wrote:
I find the phenomenon of topic drift curious. There seems to be a
recurrent pattern in this group in which a person creates an initial
topic of some Java related sort or another and the topic quickly drifts
to criticism and "bashing" of the person that started the thread.

I suspect it is proportional to the amount of good advice previously ignored.

Perhaps some people need to leave their egos at home when they visit?

True, have you considered whether your own ego might be getting in the way of your accepting good advice?

Re: the most recent round of (universally hostile-toned) replies, I'd
already mentioned that bundling stuff in a jar is not a complication I
wish to handle just yet.

You must be aware that Eclipse has a wizard for creating Jars. I find it a lot less complex than your method of encoding image data within class files seems.

Particularly as it means the app has to look
for resources in two places: in a jar with the app (where they'd be
when the app's been packaged and installed somewhere) and in my
computer's specific directory structure somewhere (where they'd be
during development). Someone mentioned putting them along the class
path and their being found automatically if they're there or in a jar
with the app; but then I need to set my class path on my development
machine to include the source directory for every project that has
resources, don't I? Ouch. Or I can track down, download, study, and use
a new build tool (when Eclipse has been serving me well so far)...it
sounds to me like if I'd gone that route I'd still be fiddling with
something merely preliminary to getting the icon to work *now*, around
48 hours later. When there's a lot more resources, and
optional/switchable ones like internationalization resources, then that
looks like a wise investment of time; when there's only the one little
32x32 gif, it seems more like a *waste* of time.

I use Eclipse, I have an image for my app in a subdirectory of my project. I have this code (and this code only) to load the image:

setIconImage(new ImageIcon(MainForm.class
.getResource("/resources/logo32.png")).getImage());

When I run the app from Eclipse it finds the image from the subdirectory in the filesystem.

After getting Eclipse to make a jar that includes the image, running the jar causes the image to be loaded from the jar instead. No change to the above code.

I just don't see the problem you seem to be struggling against. I didn't need to do anything with my classpath or change my build tool (I use plain old Eclipse without Ant etc)

Maybe I'm missing something, but it looks like you've spent more time thinking up arguments why you shouldn't try the suggestions offered than you would have spent simply trying them.
.



Relevant Pages

  • Re: help with understanding relative path problems
    ... I've developed and tested a java program in Eclipse. ... I then packed this program up into a jar file (which by the way is ... The problem is that all of the resources I've named in my program are ...
    (comp.lang.java.help)
  • Re: Giving an application a window icon in a sensible way
    ... already mentioned that bundling stuff in a jar is not a complication I ... Particularly as it means the app has to look ... for resources in two places: in a jar with the app (where they'd be ... but then I need to set my class path on my development ...
    (comp.lang.java.programmer)
  • Re: help with understanding relative path problems
    ... I've developed and tested a java program in Eclipse. ... I then packed this program up into a jar file (which by the way is ... The problem is that all of the resources I've named in my program are ...
    (comp.lang.java.help)
  • help with understanding relative path problems
    ... I've developed and tested a java program in Eclipse. ... I then packed this program up into a jar file (which by the way is ... The problem is that all of the resources I've named in my program are ... will execute a program from? ...
    (comp.lang.java.help)
  • Re: Displaying Images
    ... called resources, but as far as I can tell, the only way these images get ... I don't mind if I have to add these images to the JAR after I've compiled, ... Put the image file in a directory called images. ... Change the name of the images directory when you test just to make sure. ...
    (comp.lang.java.gui)