aspose file tools*
The moose likes I/O and Streams and the fly likes How to get Beep Sound during error?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to get Beep Sound during error??" Watch "How to get Beep Sound during error??" New topic
Author

How to get Beep Sound during error??

Murali Obla
Ranch Hand

Joined: Nov 18, 2001
Posts: 40
Hello Folks,
I wanted to give beep sound using system own inside speaker whenever my application encounters error ,but I donot want to use external speaker ,how I could do this using java.
Thanks in Advance
Murali


"Excellence is never an accident; it is always the result of high intention, sincere effort, intelligent direction, skillful execution, and the vision to see obstacles as opportunities"
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
System.out.println("\007");


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I don't know if this next one will use the system speaker. I suspect not...
java.awt.Toolkit.getDefaultToolkit().beep() ;
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
In the first suggestion, I've noticed that if your IDE is capturing the output, the beep won't be heard. If run from the command line, the beep is heard from the system speaker.
And I'm pretty sure the second suggestion won't play through the system speaker.
Good Luck.
Murali Obla
Ranch Hand

Joined: Nov 18, 2001
Posts: 40
Thanks for your reply Dirk,

I will try this line of code and let you know.
Regards,
Murali
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 671
I heard the beep when running class from command line (first method). Interesting!
Can we have other sound other than just beep?
Thanks.
Bruce


BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Lee Meador
Greenhorn

Joined: Nov 30, 2004
Posts: 1
You can also use a line like this:

UIManager.getLookAndFeel().provideErrorFeedback(component);

where component is the component that is generating the error. This is useful in input verifiers and such.


-- Lee Meador
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get Beep Sound during error??