<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    I wrote to Microsoft and they suggested to use the New APIs
    (ToastNotification) meant for the purpose<br>
    <br>
<a class="moz-txt-link-freetext" href="https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/toast-notifications-overview">https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/toast-notifications-overview</a>
    <br>
<a class="moz-txt-link-freetext" href="https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/send-local-toast-desktop-cpp-wrl">https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/send-local-toast-desktop-cpp-wrl</a><br>
    <br>
    Shell_NotifyIcon API is clearly unsupported after 25/30 years on a
    modern OS.<br>
    <br>
    If you are a Java programmer, you can't send an OS notification.<br>
    <br>
    OS Notifications are very crucial to most apps this days, <br>
    I can't imagine how Java can overlook it.<br>
    <br>
    Since you don't accept it as a bug (Oracle is closing all the bug
    reports from people on this), <br>
    I opened a feature request on this in the hope that someone wise
    will look at it.<br>
    <br>
    Kind Regards,<br>
    Davide<br>
    <br>
    <br>
    <div class="moz-cite-prefix">Il 08/01/2024 22:05, Davide Perini ha
      scritto:<br>
    </div>
    <blockquote type="cite"
      cite="mid:310e0659-fd0f-45c7-b462-7755a0144c34@dpsoftware.org">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      Thanks for the explanation Aleksei <br>
      but can you explain me what is the OpenJDK direction please?<br>
      <br>
      Suppose that you have a feature like this one, a simple
      notifications.<br>
      Java worked well with Windows notifications until Win10,<br>
      then Microsoft changed the APIs for notifications in Win11.<br>
      <br>
      Isn't OpenJDK supposed to adapt to the new Windows APIs?<br>
      <br>
      Does OpenJDK supports Windows 11 or not?<br>
      <br>
      It's a little "weird" to close an issue by saying that Java uses
      the same way to do the same thing since Windows 95 <br>
      and that it's a Microsoft problem if they changed the way to send
      notifications to the OS.<br>
      <br>
      Java should support Microsoft Windows, it isn't Microsoft Windows
      that should support Java, <br>
      isn't it?<br>
      <br>
      Other languages adapted their APIs for the new notifications
      system, like everyone should expect from a modern language, <br>
      after 2 years from the release of Win 11,<br>
      Oracle says that it worked since Windows 95, so it is ok to have a
      broken API in JDK because it worked before, they are the ones who
      broke it (Microsoft).<br>
      <br>
      Does Java offers a correct way to send Notifications in Win10?
      Answer: Yes<br>
      Does Java offers a correct way to send Notifications in Win11?
      Answer: No<br>
      Does other languages offers a correct way to send Notifications in
      Win11? Answer: Yes<br>
      Does current JDK APIs works as expected in Win11? <br>
      Answer: No because JDK uses an old API born with Win95 (30 years
      ago + or -) with a new OS born in 2021, this results in an
      unexcpected behaviour that doesn't work as supposed initially by
      the API.<br>
      <br>
      In the bug report you wrote:<br>
      "I can't see what Java can do to change the behaviour."<br>
      <br>
      The answer is:<br>
      "By implementing the correct API for the correct OS".<br>
      <br>
      <br>
      Java is currently not able to correctly send a Notification in
      Windows 11.<br>
      <br>
      <br>
      I see a bug there, if you don't see it, <br>
      I'm pretty worried of the new JDK direction.<br>
      <br>
      Thanks<br>
      Davide<br>
      <br>
      <br>
      Il 08/01/2024 20:55, Aleksei Ivanov ha scritto:<br>
      <blockquote type="cite"
        cite="mid:77e4ab4a-3813-4e83-b464-a4400dbe05f2@oracle.com">
        <meta http-equiv="Content-Type"
          content="text/html; charset=UTF-8">
        On 2024-01-08 19:30, Davide Perini wrote:<br>
        <blockquote type="cite"
          cite="mid:9ecd6e22-3eb1-489b-b166-652a2fd1bf22@dpsoftware.org">
          Thanks for the Answer Aleksei,<br>
          I have a lot of Windows apps that uses notifications without
          problems.<br>
          <br>
          even a simple python program like this works correctly.<br>
          <div style="background-color:#1e1f22;color:#bcbec4">
            <pre
style="font-family:'JetBrains Mono',monospace;font-size:9,8pt;"><span
            style="color:#cf8e6d;">from </span>win11toast <span
            style="color:#cf8e6d;">import </span>toast

toast(<span style="color:#6aab73;">'Hello'</span>, <span
            style="color:#6aab73;">'Click to run python script'</span>)</pre>
          </div>
        </blockquote>
        <br>
        Python could use newer WinRT APIs [6], in particular
        ToastNotification class [7] which provide richer interface for
        the toast notifications. The package name ‘toast’ hints it uses
        the newer APIs.<br>
        <br>
        <blockquote type="cite"
          cite="mid:9ecd6e22-3eb1-489b-b166-652a2fd1bf22@dpsoftware.org">is
          it possible that Microsoft changed the way how to create
          Notifications in Windows 11 and Java still uses the way it
          worked in Windows 7?<br>
        </blockquote>
        <br>
        Perhaps, Microsoft changed how they handle notifications in
        Windows 11. In Windows 10, the notifications created with a Java
        app remain in Action / Notification centre.<br>
        <br>
        Java uses Shell_NotifyIcon [8] function that has been available
        since Windows 95.<br>
        <br>
        -- <br>
        Regards,<br>
        Alexey<br>
        <br>
        [6] <a class="moz-txt-link-freetext"
href="https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/"
          moz-do-not-send="true">https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/</a><br>
        [7] <a class="moz-txt-link-freetext"
href="https://learn.microsoft.com/en-us/uwp/api/windows.ui.notifications.toastnotification?view=winrt-22621"
          moz-do-not-send="true">https://learn.microsoft.com/en-us/uwp/api/windows.ui.notifications.toastnotification?view=winrt-22621</a><br>
        [8] <a class="moz-txt-link-freetext"
href="https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shell_notifyiconw"
          moz-do-not-send="true">https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shell_notifyiconw</a><br>
        <br>
        <blockquote type="cite"
          cite="mid:9ecd6e22-3eb1-489b-b166-652a2fd1bf22@dpsoftware.org">
          <br>
          Thanks<br>
          Davide<br>
          <br>
          <br>
          <br>
          <div class="moz-cite-prefix">Il 08/01/2024 17:59, Aleksei
            Ivanov ha scritto:<br>
          </div>
          <blockquote type="cite"
            cite="mid:b82b650e-63d0-4b61-af42-25b693d512a8@oracle.com">Hi
            Davide, <br>
            <br>
            The bug that you reported has been moved to JDK project in
            JBS, you can view it as JDK-8315647 [1]. You should've
            received a link to it. <br>
            <br>
            <blockquote type="cite">Is there a way to workaround this
              JDK bug? <br>
              I opened a bug report months ago but no one answered. </blockquote>
            <br>
            What kind of answer did you expect to receive? <br>
            <br>
            You already asked this question on this mailing list in
            August [2]. I replied to your question [3]. Nothing has
            changed since August. It is not a bug in Java because a
            native Win32 app behaves the same way. <br>
            <br>
            I compiled and tested the sample [4], it behaves in Windows
            11 as Java does: the displayed balloon notification does not
            go to notification centre. However, if I open notification
            centre while the balloon is displayed, it remains there. If
            I disable "Show notification banners" and leave "Show
            notifications in notification centre" enabled, the balloon
            goes directly to notification centre without displaying a
            banner. <br>
            <br>
            You can compile and test the sample too: <br>
            <br>
            git clone --filter=<a class="moz-txt-link-freetext"
              href="blob:none" moz-do-not-send="true">blob:none</a>
            --sparse <a class="moz-txt-link-freetext"
href="https://urldefense.com/v3/__https://github.com/microsoft/Windows-classic-samples.git__;!!ACWV5N9M2RV99hQ!NLmQsIei56bZm5IGVWA45k6g1Dduh_MFpShFK0TzjLM7OJHlH90je29IlZRa410GYcehUmNb21kyLplVv8fTzwWsci7s6yw2$"
              moz-do-not-send="true">https://github.com/microsoft/Windows-classic-samples.git</a>
            windows-samples <br>
            cd windows-samples <br>
            git sparse-checkout add
            Samples/Win7Samples/winui/shell/appshellintegration/NotificationIcon
            <br>
            <br>
            Navigate to the NotificationIcon folder and open
            NotificationIcon.sln in Visual Studio to compile and run it.
            <br>
            <br>
            If required, I can attach the compiled version of the
            application. <br>
            <br>
            <br>
            I have closed JDK-8315647 as duplicate of JDK-8310352 [5]. <br>
            <br>
          </blockquote>
          <br>
        </blockquote>
        <br>
      </blockquote>
      <br>
    </blockquote>
    <br>
  </body>
</html>