tags:

views:

74

answers:

5

First I have read all questions about this subject, so this is not a repeated question.

What I want to ask about, how an application written in Java (such as eclipse) uses an icon instead of the default jar icons.

I don't matter about compatibility, I always can make 2 different versions of my program to Windows and Linux.

How to make it in Linux and Windows.

Thanks very much.

A: 

I use NetBeans, so if you aren't using that, I don't quite know. But, when you select the window, there is an option in the properties window for an icon file. When you build the .jar, that icon should be built in with the program.

Azmisov
Unfortunately, I'm stick with eclipse as I'm using SWT and WindowBuilder plugins.
Islam Hassan
A: 

Check out the Java tutorial. Is it what you need?

MByD
Sorry for not being determined in my question. I'm asking about changing the icon which i double click on to open the jar file, not the top left window icon
Islam Hassan
A: 

If you're talking about the actual application icon in, say, Windows, you can't change it (programmatically). That's determined by the OS. Although you can change it in your OS in Folder Options.

You can, however, set the window (read: JFrame) icon image using setIconImage().

Tyler
+1  A: 

In the case of programs like eclipse, which are written in java and have a specific icon in Windows (or Linux or Mac for that matter), they actually have an OS specific executable file, e.g. eclipse.exe for windows, that initialises the java program.

It is this executable that contains the application icon, not the Java program. If you want to do the same, you'll need to create the executable 'front door', as it were, and give it an icon.

If it's just for your own personal aesthetics, just create a short cut to the jar file and change the icon of the shortcut.

Cyntech
Thanks very much, that answers my question.
Islam Hassan
A: 

If the application is launched using Java Web Start, an application icon can be specified for use in desktop shortcuts and menu items.

Note that this icon is not attached directly to the Jar, but since the end user never sees or has to deal with a Jar, that should not be a problem.

Andrew Thompson