4
votes

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?

1
You may be forced to find a JNA/JNI based solutionMadProgrammer
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
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 processMadProgrammer
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
Unless they've updated AWT/Swing (JavaFX?) Window#setIconImages to actually work under MacOS, I can't see away around it without using JNI/JNAMadProgrammer

1 Answers

6
votes

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