Playing a system sound in Windows

The public knowledge pool and discussion forum of the OWS community. Do not post confidential information here!
marek
Posts: 6
Joined: 22 Jun 2022, 19:18

Playing a system sound in Windows

Post by marek »

We're facing an issue with the access to system sounds defined in Windows. In our application we're playing a sound defined in Windows OS using the java.awt.Toolkit:

Runnable sound =(Runnable)Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.exclamation");

But this does not work in OpenWebStart, is there a way to access a sound defined in Windows OS?

Janak Mulani
Posts: 971
Joined: 24 Mar 2020, 13:37

Re: Playing a system sound in Windows

Post by Janak Mulani »

Which JRE is being used to run the jnlp application? OWS only launches the jnlp application with a JRE that matches the one specified in the jnlp file. Perhaps you need to give some permissions in the policy file of the JRE or you need to set some JVM args in the Jnlp to make your application work. Please check OWS log files for any errors / logs from your application.

marek
Posts: 6
Joined: 22 Jun 2022, 19:18

Re: Playing a system sound in Windows

Post by marek »

We're using the JDK-21.0.2 from Oracle configured in OpenWebStart 1.10.1, in the JNLP we've set <j2se version="17+" href="http://java.sun.com/products/autodl/j2se"/>

Unfortunately there are no errors in log file. What policy file of the JRE do you have in mind? Are there any specific JVM args which could block this access to the Windows key win.sound.exclamation? The strange thing is, that sound in general works just fine, for example if there is an error in the Forms application, then there is sound when the error window pops up.

marek
Posts: 6
Joined: 22 Jun 2022, 19:18

Re: Playing a system sound in Windows

Post by marek »

Found the issue in our internal properties, OWS is working just fine for both:

Toolkit.getDefaultToolkit().beep();

and

Runnable sound = (Runnable)Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.question");
if (sound != null) {
sound.run();
}

Thank you very much for the support and sorry for the inconvenience.

Post Reply