5

I am trying to set the Dock icon in Java 9.

With previous versions of Java this was possible with something like com.apple.eawt.Application.getApplication().setDockIconImage(image); but unfortunately with Java 9 the Application class is obsolete and inaccesible (maybe also missing?).

For all other tasks found in Application class, the java.awt.Desktop class took this functionality, all but the Dock manipulation.

In JEP 272 this change is mentioned, as well as the idea that Dock is too much Apple-oriented (for me all are Apple oriented) and there is no clear explanation about it.

A Google search also has pre-9 information on how to deal with this.

Does anyone have any idea how's done now with Java 9?

Panayotis
  • 1,792
  • 23
  • 32
  • You may be forced to find a JNA/JNI based solution – MadProgrammer Jun 04 '17 at 23:27
  • Of course with native programming, everything is possible. But it is funny that, although acknowledged, it is the only thing that is not implemented - all other methods are. Moreover handling images is not the most elegant method in native universe. – Panayotis Jun 04 '17 at 23:32
  • I've not seen Java 9 at all and it's always been a "joy" getting things to run on MacOS. There are a number of Windows centric APIs that do the "extra" stuff on window (progress bar in taskbar item for example), so it's not unreasonable to think that a MacOS based library could/should exist - if you think it needs to be updated, then you should make the suggestion as part of the improvement process – MadProgrammer Jun 04 '17 at 23:38
  • Yes, probably, but as I said the Desktop class in Java 9 is heavily polluted with all the mac stuff.. except the dock icon. I suspect that this functionality has moved to some onther class but it is practically impossible to find where. – Panayotis Jun 04 '17 at 23:40
  • Unless they've updated AWT/Swing (JavaFX?) `Window#setIconImages` to actually work under MacOS, I can't see away around it without using JNI/JNA – MadProgrammer Jun 04 '17 at 23:45
  • Unfortunately no... this was my first idea to try, with no luck – Panayotis Jun 04 '17 at 23:52
  • I'd consider that the bug that needs to be fixed :p – MadProgrammer Jun 05 '17 at 00:26

1 Answers1

7

Have you tried setIconImage in the new java.awt.Taskbar class?

dmolony
  • 1,125
  • 9
  • 23
Snowy_1803
  • 656
  • 2
  • 8
  • 24