I have here nice and working code
InputStream img = Main.class.getResourcesAsStream("/optician/icon.png");
BufferedImage myImg=ImageIO.read(img);
setIconImage(myImg);
and here is also try/catch but i did not write this. So, this is working fine anywhere, in JFrame, in taskbar, everywhere is working fine but in my Desktop is again Java coffee cup, it is not changed with this code. Any idea how i can change Desktop Icon ? I can't find any solution...
Operating systems assign icons based on file associations. Because your code is compiled to a jar, the OS is going to give it the icon it gives to all jar files.
To give your application a custom icon, you have to compile it to an executable or use an executable to launch the jar. If the OS knows that a file is an executable, it will check to see if it supplies an icon in its binary, and if it doesn't, it will give it the default icon.
There are numerous third party programs that can make executables out of jars. You can search using your favorite search engine to find a suitable program (something along the lines of "jar to executable" or "jar to exe")